From 9b4b2e82bb9075a8529dc9c36dc0f23015db792c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Sep 2022 19:48:29 +0000 Subject: [PATCH 1/9] chore: remove obsolete service config files PiperOrigin-RevId: 472492863 Source-Link: https://github.com/googleapis/googleapis/commit/725381dc13c25c5fdc30fc9a660e5f9c35378f08 Source-Link: https://github.com/googleapis/googleapis-gen/commit/16aebe24e817c24e6192746edc522d70036dd772 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZhZWJlMjRlODE3YzI0ZTYxOTI3NDZlZGM1MjJkNzAwMzZkZDc3MiJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 65 + .../google/cloud/vision/v1/geometry.proto | 68 + .../cloud/vision/v1/image_annotator.proto | 1043 ++++++ .../cloud/vision/v1/product_search.proto | 124 + .../vision/v1/product_search_service.proto | 1022 ++++++ .../cloud/vision/v1/text_annotation.proto | 258 ++ .../cloud/vision/v1/web_detection.proto | 104 + ...ge_annotator.async_batch_annotate_files.js | 73 + ...e_annotator.async_batch_annotate_images.js | 78 + .../image_annotator.batch_annotate_files.js | 73 + .../image_annotator.batch_annotate_images.js | 72 + ...oduct_search.add_product_to_product_set.js | 70 + .../v1/product_search.create_product.js | 75 + .../v1/product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../v1/product_search.delete_product.js | 63 + .../v1/product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1/product_search.get_product.js | 63 + .../v1/product_search.get_product_set.js | 63 + .../v1/product_search.get_reference_image.js | 63 + .../v1/product_search.import_product_sets.js | 68 + .../v1/product_search.list_product_sets.js | 72 + .../v1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../v1/product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 70 + .../v1/product_search.update_product.js | 70 + .../v1/product_search.update_product_set.js | 68 + ...ippet_metadata.google.cloud.vision.v1.json | 1043 ++++++ owl-bot-staging/v1/src/index.ts | 27 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 ++ .../v1/src/v1/image_annotator_client.ts | 921 ++++++ .../src/v1/image_annotator_client_config.json | 46 + .../v1/src/v1/image_annotator_proto_list.json | 8 + owl-bot-staging/v1/src/v1/index.ts | 20 + .../v1/src/v1/product_search_client.ts | 2654 +++++++++++++++ .../src/v1/product_search_client_config.json | 121 + .../v1/src/v1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_image_annotator_v1.ts | 784 +++++ .../v1/test/gapic_product_search_v1.ts | 2836 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1p1beta1/.eslintignore | 7 + owl-bot-staging/v1p1beta1/.eslintrc.json | 3 + owl-bot-staging/v1p1beta1/.gitignore | 14 + owl-bot-staging/v1p1beta1/.jsdoc.js | 55 + owl-bot-staging/v1p1beta1/.mocharc.js | 33 + owl-bot-staging/v1p1beta1/.prettierrc.js | 22 + owl-bot-staging/v1p1beta1/README.md | 1 + .../v1p1beta1/linkinator.config.json | 16 + owl-bot-staging/v1p1beta1/package.json | 64 + .../cloud/vision/v1p1beta1/geometry.proto | 53 + .../vision/v1p1beta1/image_annotator.proto | 617 ++++ .../vision/v1p1beta1/text_annotation.proto | 251 ++ .../vision/v1p1beta1/web_detection.proto | 103 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p1beta1.json | 55 + owl-bot-staging/v1p1beta1/src/index.ts | 25 + .../src/v1p1beta1/gapic_metadata.json | 33 + .../src/v1p1beta1/image_annotator_client.ts | 373 +++ .../image_annotator_client_config.json | 31 + .../v1p1beta1/image_annotator_proto_list.json | 6 + .../v1p1beta1/src/v1p1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p1beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p1beta1.ts | 209 ++ owl-bot-staging/v1p1beta1/tsconfig.json | 19 + owl-bot-staging/v1p1beta1/webpack.config.js | 64 + owl-bot-staging/v1p2beta1/.eslintignore | 7 + owl-bot-staging/v1p2beta1/.eslintrc.json | 3 + owl-bot-staging/v1p2beta1/.gitignore | 14 + owl-bot-staging/v1p2beta1/.jsdoc.js | 55 + owl-bot-staging/v1p2beta1/.mocharc.js | 33 + owl-bot-staging/v1p2beta1/.prettierrc.js | 22 + owl-bot-staging/v1p2beta1/README.md | 1 + .../v1p2beta1/linkinator.config.json | 16 + owl-bot-staging/v1p2beta1/package.json | 64 + .../cloud/vision/v1p2beta1/geometry.proto | 67 + .../vision/v1p2beta1/image_annotator.proto | 793 +++++ .../vision/v1p2beta1/text_annotation.proto | 258 ++ .../vision/v1p2beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p2beta1.json | 95 + owl-bot-staging/v1p2beta1/src/index.ts | 25 + .../src/v1p2beta1/gapic_metadata.json | 43 + .../src/v1p2beta1/image_annotator_client.ts | 492 +++ .../image_annotator_client_config.json | 36 + .../v1p2beta1/image_annotator_proto_list.json | 6 + .../v1p2beta1/src/v1p2beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p2beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p2beta1.ts | 337 ++ owl-bot-staging/v1p2beta1/tsconfig.json | 19 + owl-bot-staging/v1p2beta1/webpack.config.js | 64 + owl-bot-staging/v1p3beta1/.eslintignore | 7 + owl-bot-staging/v1p3beta1/.eslintrc.json | 3 + owl-bot-staging/v1p3beta1/.gitignore | 14 + owl-bot-staging/v1p3beta1/.jsdoc.js | 55 + owl-bot-staging/v1p3beta1/.mocharc.js | 33 + owl-bot-staging/v1p3beta1/.prettierrc.js | 22 + owl-bot-staging/v1p3beta1/README.md | 1 + .../v1p3beta1/linkinator.config.json | 16 + owl-bot-staging/v1p3beta1/package.json | 65 + .../cloud/vision/v1p3beta1/geometry.proto | 68 + .../vision/v1p3beta1/image_annotator.proto | 832 +++++ .../vision/v1p3beta1/product_search.proto | 124 + .../v1p3beta1/product_search_service.proto | 971 ++++++ .../vision/v1p3beta1/text_annotation.proto | 258 ++ .../vision/v1p3beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p3beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p3beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + ..._search.remove_product_from_product_set.js | 70 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p3beta1.json | 891 ++++++ owl-bot-staging/v1p3beta1/src/index.ts | 27 + .../src/v1p3beta1/gapic_metadata.json | 253 ++ .../src/v1p3beta1/image_annotator_client.ts | 671 ++++ .../image_annotator_client_config.json | 36 + .../v1p3beta1/image_annotator_proto_list.json | 8 + .../v1p3beta1/src/v1p3beta1/index.ts | 20 + .../src/v1p3beta1/product_search_client.ts | 2538 +++++++++++++++ .../product_search_client_config.json | 116 + .../v1p3beta1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p3beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p3beta1.ts | 486 +++ .../test/gapic_product_search_v1p3beta1.ts | 2692 ++++++++++++++++ owl-bot-staging/v1p3beta1/tsconfig.json | 19 + owl-bot-staging/v1p3beta1/webpack.config.js | 64 + owl-bot-staging/v1p4beta1/.eslintignore | 7 + owl-bot-staging/v1p4beta1/.eslintrc.json | 3 + owl-bot-staging/v1p4beta1/.gitignore | 14 + owl-bot-staging/v1p4beta1/.jsdoc.js | 55 + owl-bot-staging/v1p4beta1/.mocharc.js | 33 + owl-bot-staging/v1p4beta1/.prettierrc.js | 22 + owl-bot-staging/v1p4beta1/README.md | 1 + .../v1p4beta1/linkinator.config.json | 16 + owl-bot-staging/v1p4beta1/package.json | 65 + .../google/cloud/vision/v1p4beta1/face.proto | 60 + .../cloud/vision/v1p4beta1/geometry.proto | 70 + .../vision/v1p4beta1/image_annotator.proto | 966 ++++++ .../vision/v1p4beta1/product_search.proto | 127 + .../v1p4beta1/product_search_service.proto | 1039 ++++++ .../vision/v1p4beta1/text_annotation.proto | 260 ++ .../vision/v1p4beta1/web_detection.proto | 106 + ...ge_annotator.async_batch_annotate_files.js | 62 + ...e_annotator.async_batch_annotate_images.js | 67 + .../image_annotator.batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 77 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p4beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p4beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 71 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ++++++ owl-bot-staging/v1p4beta1/src/index.ts | 27 + .../src/v1p4beta1/gapic_metadata.json | 283 ++ .../src/v1p4beta1/image_annotator_client.ts | 848 +++++ .../image_annotator_client_config.json | 46 + .../v1p4beta1/image_annotator_proto_list.json | 9 + .../v1p4beta1/src/v1p4beta1/index.ts | 20 + .../src/v1p4beta1/product_search_client.ts | 2661 ++++++++++++++++ .../product_search_client_config.json | 120 + .../v1p4beta1/product_search_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p4beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p4beta1.ts | 670 ++++ .../test/gapic_product_search_v1p4beta1.ts | 2836 +++++++++++++++++ owl-bot-staging/v1p4beta1/tsconfig.json | 19 + owl-bot-staging/v1p4beta1/webpack.config.js | 64 + 218 files changed, 43496 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1p1beta1/.eslintignore create mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p1beta1/.gitignore create mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p1beta1/README.md create mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p1beta1/package.json create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json create mode 100644 owl-bot-staging/v1p1beta1/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p2beta1/.eslintignore create mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p2beta1/.gitignore create mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p2beta1/README.md create mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p2beta1/package.json create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json create mode 100644 owl-bot-staging/v1p2beta1/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts create mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p3beta1/.eslintignore create mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p3beta1/.gitignore create mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p3beta1/README.md create mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p3beta1/package.json create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json create mode 100644 owl-bot-staging/v1p3beta1/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p4beta1/.eslintignore create mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p4beta1/.gitignore create mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p4beta1/README.md create mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p4beta1/package.json create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json create mode 100644 owl-bot-staging/v1p4beta1/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto new file mode 100644 index 00000000..7e0d24c2 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto new file mode 100644 index 00000000..10464b0e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto @@ -0,0 +1,1043 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search.proto"; +import "google/cloud/vision/v1/text_annotation.proto"; +import "google/cloud/vision/v1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1/images:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1/files:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/images:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/files:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateImages requests. It does + // not work for AsyncBatchAnnotateImages requests. + bytes content = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + + // Left cheek center. + LEFT_CHEEK_CENTER = 35; + + // Right cheek center. + RIGHT_CHEEK_CENTER = 36; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 3; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto new file mode 100644 index 00000000..a2a98505 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto new file mode 100644 index 00000000..65680d90 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto @@ -0,0 +1,1022 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.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/vision/v1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or + // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are + // still supported, but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1.Product.product_category], and the + // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a + // space (" "). You can update the `display_name` later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto new file mode 100644 index 00000000..9c07c322 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/cloud/vision/v1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more +// detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto new file mode 100644 index 00000000..369a1350 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..7d7ed138 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..70be298e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..528c4d1f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..2f57a691 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..1826ada2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js new file mode 100644 index 00000000..9e064a95 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { + // [START vision_v1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js new file mode 100644 index 00000000..5c580189 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js new file mode 100644 index 00000000..6175cef1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js new file mode 100644 index 00000000..8d58541b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js new file mode 100644 index 00000000..5c5b8125 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js new file mode 100644 index 00000000..18a64743 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js new file mode 100644 index 00000000..27e014db --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js new file mode 100644 index 00000000..fa80ab00 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js new file mode 100644 index 00000000..b25fb5e6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js new file mode 100644 index 00000000..859e0f5a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js new file mode 100644 index 00000000..66a071b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js new file mode 100644 index 00000000..8fa795f6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..3e9871fc --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js new file mode 100644 index 00000000..f7175d39 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js new file mode 100644 index 00000000..0dae0b9b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..ad66ef6b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js new file mode 100644 index 00000000..d8fd49f9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js new file mode 100644 index 00000000..26bf5ed6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json new file mode 100644 index 00000000..def101a1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json @@ -0,0 +1,1043 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1.OutputConfig" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..67a41d87 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ImageAnnotatorClient = v1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1.ImageAnnotatorClient; +const ProductSearchClient = v1.ProductSearchClient; +type ProductSearchClient = v1.ProductSearchClient; +export {v1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..13fb1dac --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts new file mode 100644 index 00000000..ea2296c7 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client.ts @@ -0,0 +1,921 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. + * 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/image_annotator.batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * 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/image_annotator.batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + 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.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + 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.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json new file mode 100644 index 00000000..08f87df9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts new file mode 100644 index 00000000..7e03c2b8 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client.ts @@ -0,0 +1,2654 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.create_product_set.js + * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.get_product_set.js + * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.update_product_set.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product_set.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.create_product.js + * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.get_product.js + * region_tag:vision_v1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.update_product.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.create_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.get_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.add_product_to_product_set.js + * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products.js + * region_tag:vision_v1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js + * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products_in_product_set.js + * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json new file mode 100644 index 00000000..b7db1b90 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client_config.json @@ -0,0 +1,121 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts new file mode 100644 index 00000000..64295d79 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts @@ -0,0 +1,784 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts new file mode 100644 index 00000000..e8ec2247 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_product_search_v1.ts @@ -0,0 +1,2836 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1.ProductSearchClient({ + 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 productsearchModule.v1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'vision', + filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json new file mode 100644 index 00000000..ac8fd32c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto new file mode 100644 index 00000000..6d46d9c3 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// 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 bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto new file mode 100644 index 00000000..729a0fa0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -0,0 +1,617 @@ +// 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.vision.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p1beta1/geometry.proto"; +import "google/cloud/vision/v1p1beta1/text_annotation.proto"; +import "google/cloud/vision/v1p1beta1/web_detection.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p1beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } +} + +// Users describe the type of Google Cloud Vision API tasks to perform over +// images by using *Feature*s. Each Feature indicates a type of image +// detection task to perform. Features encode the Cloud Vision API +// vertical to operate on and the number of top-scoring results to return. +message Feature { + // Type of image feature. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run OCR. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run computer vision models to compute image safe-search properties. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". + string model = 3; +} + +// External image source (Google Cloud Storage image location). +message ImageSource { + // NOTE: For new code `image_uri` below is preferred. + // Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + string gcs_image_uri = 1; + + // Image URI which supports: + // 1) Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + // 2) Publicly accessible image HTTP/HTTPS URL. + // This is preferred over the legacy `gcs_image_uri` above. When both + // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location. If both `content` and `source` + // are provided for an image, `content` takes precedence and is + // used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // lat/long rectangle that specifies the location of the image. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto new file mode 100644 index 00000000..f85cc44d --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto @@ -0,0 +1,251 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +import "google/cloud/vision/v1p1beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width in pixels. + int32 width = 2; + + // Page height in pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto new file mode 100644 index 00000000..c50e1ad6 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..eb0fe422 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json new file mode 100644 index 00000000..dbece339 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p1beta1", + "version": "v1p1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts new file mode 100644 index 00000000..1137dce5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; +const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +export {v1p1beta1, ImageAnnotatorClient}; +export default {v1p1beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json new file mode 100644 index 00000000..2dc79630 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts new file mode 100644 index 00000000..092acab0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p1beta1 + */ +export class ImageAnnotatorClient { + 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}; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p1beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. + * 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/v1p1beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json new file mode 100644 index 00000000..469fb95c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.vision.v1p1beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..35609fc8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts new file mode 100644 index 00000000..a7fde53a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts @@ -0,0 +1,209 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1p1beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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: 'vision', + filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json new file mode 100644 index 00000000..ac8fd32c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto new file mode 100644 index 00000000..e9fec20b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto @@ -0,0 +1,67 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto new file mode 100644 index 00000000..5fc3163c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -0,0 +1,793 @@ +// 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.vision.v1p2beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p2beta1/geometry.proto"; +import "google/cloud/vision/v1p2beta1/text_annotation.proto"; +import "google/cloud/vision/v1p2beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p2beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run async image detection and annotation for a list of generic files (e.g. + // PDF) which may contain multiple pages and multiple images per page. + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p2beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file on GCS. + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a GCS + // object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto new file mode 100644 index 00000000..af568194 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +import "google/cloud/vision/v1p2beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto new file mode 100644 index 00000000..2decb859 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..92074c3a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..793ec83e --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json new file mode 100644 index 00000000..c843af75 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json @@ -0,0 +1,95 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p2beta1", + "version": "v1p2beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts new file mode 100644 index 00000000..0e8fea74 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; +const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +export {v1p2beta1, ImageAnnotatorClient}; +export default {v1p2beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json new file mode 100644 index 00000000..116ff853 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts new file mode 100644 index 00000000..399a91e4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts @@ -0,0 +1,492 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p2beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p2beta1 + */ +export class ImageAnnotatorClient { + 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; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p2beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. + * 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/v1p2beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run async image detection and annotation for a list of generic files (e.g. + * PDF) which may contain multiple pages and multiple images per page. + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json new file mode 100644 index 00000000..367627eb --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p2beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..2b5904f9 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts new file mode 100644 index 00000000..770639d0 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts @@ -0,0 +1,337 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p2beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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: 'vision', + filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p3beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1p3beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto new file mode 100644 index 00000000..c2c524fb --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto new file mode 100644 index 00000000..ca0b4e86 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -0,0 +1,832 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search.proto"; +import "google/cloud/vision/v1p3beta1/text_annotation.proto"; +import "google/cloud/vision/v1p3beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p3beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = + 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto new file mode 100644 index 00000000..86ea1a06 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto new file mode 100644 index 00000000..daf1d0dd --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto @@ -0,0 +1,971 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. All Products and ReferenceImages in the + // ProductSet will be deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only display_name, description and labels can be updated right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + // + // Possible errors: + // + // * Returns NOT_FOUND if the product does not exist. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the reference image does not exist. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND If the Product is not found under the ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories + // "homegoods", "apparel", and "toys" are still supported, but these should + // not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 100 product_labels. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this field is 0. + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 6 columns. + // 1. image_uri + // 2, image_id + // 3. product_set_id + // 4. product_id + // 5, product_category + // 6, product_display_name + // 7, labels + // 8. bounding_poly + // + // Columns 1, 3, 4, and 5 are required, other columns are optional. A new + // ProductSet/Product with the same id will be created on the fly + // if the ProductSet/Product specified by product_set_id/product_id does not + // exist. + // + // The image_id field is optional but has to be unique if provided. If it is + // empty, we will automatically assign an unique id to the image. + // + // The product_display_name field is optional. If it is empty, a space (" ") + // is used as the place holder for the product display_name, which can + // be updated later through the realtime API. + // + // If the Product with product_id already exists, the fields + // product_display_name, product_category and labels are ignored. + // + // If a Product doesn't exist and needs to be created on the fly, the + // product_display_name field refers to + // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], + // the product_category field refers to + // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], + // and the labels field refers to [Product.labels][]. + // + // Labels (optional) should be a line containing a list of comma-separated + // key-value pairs, with the format + // "key_1=value_1,key_2=value_2,...,key_n=value_n". + // + // The bounding_poly (optional) field is used to identify one region of + // interest from the image in the same manner as CreateReferenceImage. If no + // bounding_poly is specified, the system will try to detect regions of + // interest automatically. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 20MP). + // + // Also note that at most one bounding_poly is allowed per line. If the image + // contains multiple regions of interest, the csv should contain one line per + // region of interest. + // + // The bounding_poly column should contain an even number of comma-separated + // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative + // integers should be used for absolute bounding polygons, and float values + // in [0, 1] should be used for normalized bounding polygons. + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto new file mode 100644 index 00000000..633e404e --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/cloud/vision/v1p3beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto new file mode 100644 index 00000000..205dfe65 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..900c1b0b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..1b58eca1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Individual image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..96b4c8ba --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js new file mode 100644 index 00000000..ed6ac1b8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js new file mode 100644 index 00000000..90879035 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..48848360 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js new file mode 100644 index 00000000..a5872042 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..7d971bc3 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..c97f2727 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js new file mode 100644 index 00000000..c62e8ea6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js new file mode 100644 index 00000000..4def76dc --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..93ee9d82 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..23698c04 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..52033c07 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js new file mode 100644 index 00000000..454672d1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..65bc35e2 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..9deb4e05 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..45dcddaf --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js new file mode 100644 index 00000000..8d98838c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js new file mode 100644 index 00000000..cfecdb70 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json new file mode 100644 index 00000000..90042759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json @@ -0,0 +1,891 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p3beta1", + "version": "v1p3beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts new file mode 100644 index 00000000..9e656a03 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p3beta1 from './v1p3beta1'; +const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p3beta1.ProductSearchClient; +type ProductSearchClient = v1p3beta1.ProductSearchClient; +export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json new file mode 100644 index 00000000..52ae14a4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json @@ -0,0 +1,253 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p3beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts new file mode 100644 index 00000000..2114aa92 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts @@ -0,0 +1,671 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p3beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p3beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. + * 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/v1p3beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json new file mode 100644 index 00000000..75a2b706 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts new file mode 100644 index 00000000..2dacf41c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts @@ -0,0 +1,2538 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p3beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p3beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.create_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.get_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.update_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. All Products and ReferenceImages in the + * ProductSet will be deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.create_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.get_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only display_name, description and labels can be updated right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.update_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * Possible errors: + * + * * Returns NOT_FOUND if the product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.create_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the reference image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.get_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND If the Product is not found under the ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json new file mode 100644 index 00000000..ddc1e9ad --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json @@ -0,0 +1,116 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts new file mode 100644 index 00000000..66892759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts @@ -0,0 +1,486 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p3beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts new file mode 100644 index 00000000..b8a9d88b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts @@ -0,0 +1,2692 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p3beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p3beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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 productsearchModule.v1p3beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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: 'vision', + filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1p4beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto new file mode 100644 index 00000000..d2ab72f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto @@ -0,0 +1,60 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "CelebrityProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a celebrity recognition request. +message FaceRecognitionParams { + // The resource names for one or more + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity + // set is preloaded and can be specified as "builtin/default". If this is + // specified, the algorithm will try to match the faces detected in the input + // image to the Celebrities in the CelebritySets. + repeated string celebrity_set = 1; +} + +// A Celebrity is a group of Faces with an identity. +message Celebrity { + // The resource name of the preloaded Celebrity. Has the format + // `builtin/{mid}`. + string name = 1; + + // The Celebrity's display name. + string display_name = 2; + + // The Celebrity's description. + string description = 3; +} + +// Information about a face's identity. +message FaceRecognitionResult { + // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was + // matched to. + Celebrity celebrity = 1; + + // Recognition confidence. Range [0, 1]. + float confidence = 2; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto new file mode 100644 index 00000000..877fd897 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto @@ -0,0 +1,70 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto new file mode 100644 index 00000000..0fed9eea --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -0,0 +1,966 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p4beta1/face.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search.proto"; +import "google/cloud/vision/v1p4beta1/text_annotation.proto"; +import "google/cloud/vision/v1p4beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) + returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/files:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/images:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; + + // Additional recognition information. Only computed if + // image_context.face_recognition_params is provided, **and** a match is found + // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is + // sorted in order of decreasing confidence values. + repeated FaceRecognitionResult recognition_result = 16; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for face recognition. + FaceRecognitionParams face_recognition_params = 10; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only + // one AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto new file mode 100644 index 00000000..ebb428ac --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto @@ -0,0 +1,127 @@ +// 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.vision.v1p4beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a + // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for + // similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto new file mode 100644 index 00000000..df7bc7a3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto @@ -0,0 +1,1039 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of +// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of +// [Product][google.cloud.vision.v1p4beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of +// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, +// named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) + returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = + "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. + // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The + // legacy categories "homegoods", "apparel", and "toys" are still supported, + // but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference + // image. If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference + // image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this + // ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], + // and the `labels` column refers to + // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] + // field for the product to a space (" "). You can update the `display_name` + // later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto new file mode 100644 index 00000000..233c4c68 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto @@ -0,0 +1,260 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto new file mode 100644 index 00000000..7d716570 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto @@ -0,0 +1,106 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..199be36a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..8cb5197f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..2fe101f3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..f6aaa34e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..c6ef04f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js new file mode 100644 index 00000000..60ec6540 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js new file mode 100644 index 00000000..ea4c348b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..bb6709c3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference + * image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js new file mode 100644 index 00000000..63f362dc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..72ac7fec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..92f9f39c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js new file mode 100644 index 00000000..80db0f5a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js new file mode 100644 index 00000000..acba73c5 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..5dc13d64 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..3a422698 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..81e409fa --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js new file mode 100644 index 00000000..8b67070e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..869b118f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..637c1f8a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js new file mode 100644 index 00000000..5dd66449 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..af9e9c14 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this + * ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js new file mode 100644 index 00000000..3c8d60bb --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js new file mode 100644 index 00000000..6ceb8322 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json new file mode 100644 index 00000000..65c6af72 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json @@ -0,0 +1,1027 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p4beta1", + "version": "v1p4beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1p4beta1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts new file mode 100644 index 00000000..464f947a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p4beta1 from './v1p4beta1'; +const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p4beta1.ProductSearchClient; +type ProductSearchClient = v1p4beta1.ProductSearchClient; +export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json new file mode 100644 index 00000000..8338e641 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p4beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts new file mode 100644 index 00000000..cb620c40 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts @@ -0,0 +1,848 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p4beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p4beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json new file mode 100644 index 00000000..e068ba98 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts new file mode 100644 index 00000000..6e9bcc4b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts @@ -0,0 +1,2661 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p4beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of + * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, + * named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p4beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.create_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.get_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.update_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.create_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.get_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.update_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference + * image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.create_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.get_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this + * ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json new file mode 100644 index 00000000..518529b7 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json @@ -0,0 +1,120 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts new file mode 100644 index 00000000..5fb3c9d9 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts @@ -0,0 +1,670 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p4beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts new file mode 100644 index 00000000..5a2d84cc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts @@ -0,0 +1,2836 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p4beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p4beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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 productsearchModule.v1p4beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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: 'vision', + filename: './vision.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 2349ad4ed1e4b93806c699c6f9f7d04c78743141 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Sep 2022 19:51:14 +0000 Subject: [PATCH 2/9] =?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 --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 65 - .../google/cloud/vision/v1/geometry.proto | 68 - .../cloud/vision/v1/image_annotator.proto | 1043 ------ .../cloud/vision/v1/product_search.proto | 124 - .../vision/v1/product_search_service.proto | 1022 ------ .../cloud/vision/v1/text_annotation.proto | 258 -- .../cloud/vision/v1/web_detection.proto | 104 - ...ge_annotator.async_batch_annotate_files.js | 73 - ...e_annotator.async_batch_annotate_images.js | 78 - .../image_annotator.batch_annotate_files.js | 73 - .../image_annotator.batch_annotate_images.js | 72 - ...oduct_search.add_product_to_product_set.js | 70 - .../v1/product_search.create_product.js | 75 - .../v1/product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../v1/product_search.delete_product.js | 63 - .../v1/product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1/product_search.get_product.js | 63 - .../v1/product_search.get_product_set.js | 63 - .../v1/product_search.get_reference_image.js | 63 - .../v1/product_search.import_product_sets.js | 68 - .../v1/product_search.list_product_sets.js | 72 - .../v1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../v1/product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 70 - .../v1/product_search.update_product.js | 70 - .../v1/product_search.update_product_set.js | 68 - ...ippet_metadata.google.cloud.vision.v1.json | 1043 ------ owl-bot-staging/v1/src/index.ts | 27 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 -- .../v1/src/v1/image_annotator_client.ts | 921 ------ .../src/v1/image_annotator_client_config.json | 46 - .../v1/src/v1/image_annotator_proto_list.json | 8 - owl-bot-staging/v1/src/v1/index.ts | 20 - .../v1/src/v1/product_search_client.ts | 2654 --------------- .../src/v1/product_search_client_config.json | 121 - .../v1/src/v1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_image_annotator_v1.ts | 784 ----- .../v1/test/gapic_product_search_v1.ts | 2836 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1p1beta1/.eslintignore | 7 - owl-bot-staging/v1p1beta1/.eslintrc.json | 3 - owl-bot-staging/v1p1beta1/.gitignore | 14 - owl-bot-staging/v1p1beta1/.jsdoc.js | 55 - owl-bot-staging/v1p1beta1/.mocharc.js | 33 - owl-bot-staging/v1p1beta1/.prettierrc.js | 22 - owl-bot-staging/v1p1beta1/README.md | 1 - .../v1p1beta1/linkinator.config.json | 16 - owl-bot-staging/v1p1beta1/package.json | 64 - .../cloud/vision/v1p1beta1/geometry.proto | 53 - .../vision/v1p1beta1/image_annotator.proto | 617 ---- .../vision/v1p1beta1/text_annotation.proto | 251 -- .../vision/v1p1beta1/web_detection.proto | 103 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p1beta1.json | 55 - owl-bot-staging/v1p1beta1/src/index.ts | 25 - .../src/v1p1beta1/gapic_metadata.json | 33 - .../src/v1p1beta1/image_annotator_client.ts | 373 --- .../image_annotator_client_config.json | 31 - .../v1p1beta1/image_annotator_proto_list.json | 6 - .../v1p1beta1/src/v1p1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p1beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p1beta1.ts | 209 -- owl-bot-staging/v1p1beta1/tsconfig.json | 19 - owl-bot-staging/v1p1beta1/webpack.config.js | 64 - owl-bot-staging/v1p2beta1/.eslintignore | 7 - owl-bot-staging/v1p2beta1/.eslintrc.json | 3 - owl-bot-staging/v1p2beta1/.gitignore | 14 - owl-bot-staging/v1p2beta1/.jsdoc.js | 55 - owl-bot-staging/v1p2beta1/.mocharc.js | 33 - owl-bot-staging/v1p2beta1/.prettierrc.js | 22 - owl-bot-staging/v1p2beta1/README.md | 1 - .../v1p2beta1/linkinator.config.json | 16 - owl-bot-staging/v1p2beta1/package.json | 64 - .../cloud/vision/v1p2beta1/geometry.proto | 67 - .../vision/v1p2beta1/image_annotator.proto | 793 ----- .../vision/v1p2beta1/text_annotation.proto | 258 -- .../vision/v1p2beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p2beta1.json | 95 - owl-bot-staging/v1p2beta1/src/index.ts | 25 - .../src/v1p2beta1/gapic_metadata.json | 43 - .../src/v1p2beta1/image_annotator_client.ts | 492 --- .../image_annotator_client_config.json | 36 - .../v1p2beta1/image_annotator_proto_list.json | 6 - .../v1p2beta1/src/v1p2beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p2beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p2beta1.ts | 337 -- owl-bot-staging/v1p2beta1/tsconfig.json | 19 - owl-bot-staging/v1p2beta1/webpack.config.js | 64 - owl-bot-staging/v1p3beta1/.eslintignore | 7 - owl-bot-staging/v1p3beta1/.eslintrc.json | 3 - owl-bot-staging/v1p3beta1/.gitignore | 14 - owl-bot-staging/v1p3beta1/.jsdoc.js | 55 - owl-bot-staging/v1p3beta1/.mocharc.js | 33 - owl-bot-staging/v1p3beta1/.prettierrc.js | 22 - owl-bot-staging/v1p3beta1/README.md | 1 - .../v1p3beta1/linkinator.config.json | 16 - owl-bot-staging/v1p3beta1/package.json | 65 - .../cloud/vision/v1p3beta1/geometry.proto | 68 - .../vision/v1p3beta1/image_annotator.proto | 832 ----- .../vision/v1p3beta1/product_search.proto | 124 - .../v1p3beta1/product_search_service.proto | 971 ------ .../vision/v1p3beta1/text_annotation.proto | 258 -- .../vision/v1p3beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p3beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p3beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - ..._search.remove_product_from_product_set.js | 70 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p3beta1.json | 891 ------ owl-bot-staging/v1p3beta1/src/index.ts | 27 - .../src/v1p3beta1/gapic_metadata.json | 253 -- .../src/v1p3beta1/image_annotator_client.ts | 671 ---- .../image_annotator_client_config.json | 36 - .../v1p3beta1/image_annotator_proto_list.json | 8 - .../v1p3beta1/src/v1p3beta1/index.ts | 20 - .../src/v1p3beta1/product_search_client.ts | 2538 --------------- .../product_search_client_config.json | 116 - .../v1p3beta1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p3beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p3beta1.ts | 486 --- .../test/gapic_product_search_v1p3beta1.ts | 2692 ---------------- owl-bot-staging/v1p3beta1/tsconfig.json | 19 - owl-bot-staging/v1p3beta1/webpack.config.js | 64 - owl-bot-staging/v1p4beta1/.eslintignore | 7 - owl-bot-staging/v1p4beta1/.eslintrc.json | 3 - owl-bot-staging/v1p4beta1/.gitignore | 14 - owl-bot-staging/v1p4beta1/.jsdoc.js | 55 - owl-bot-staging/v1p4beta1/.mocharc.js | 33 - owl-bot-staging/v1p4beta1/.prettierrc.js | 22 - owl-bot-staging/v1p4beta1/README.md | 1 - .../v1p4beta1/linkinator.config.json | 16 - owl-bot-staging/v1p4beta1/package.json | 65 - .../google/cloud/vision/v1p4beta1/face.proto | 60 - .../cloud/vision/v1p4beta1/geometry.proto | 70 - .../vision/v1p4beta1/image_annotator.proto | 966 ------ .../vision/v1p4beta1/product_search.proto | 127 - .../v1p4beta1/product_search_service.proto | 1039 ------ .../vision/v1p4beta1/text_annotation.proto | 260 -- .../vision/v1p4beta1/web_detection.proto | 106 - ...ge_annotator.async_batch_annotate_files.js | 62 - ...e_annotator.async_batch_annotate_images.js | 67 - .../image_annotator.batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 77 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p4beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p4beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 71 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ------ owl-bot-staging/v1p4beta1/src/index.ts | 27 - .../src/v1p4beta1/gapic_metadata.json | 283 -- .../src/v1p4beta1/image_annotator_client.ts | 848 ----- .../image_annotator_client_config.json | 46 - .../v1p4beta1/image_annotator_proto_list.json | 9 - .../v1p4beta1/src/v1p4beta1/index.ts | 20 - .../src/v1p4beta1/product_search_client.ts | 2661 ---------------- .../product_search_client_config.json | 120 - .../v1p4beta1/product_search_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p4beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p4beta1.ts | 670 ---- .../test/gapic_product_search_v1p4beta1.ts | 2836 ----------------- owl-bot-staging/v1p4beta1/tsconfig.json | 19 - owl-bot-staging/v1p4beta1/webpack.config.js | 64 - src/v1p3beta1/image_annotator_client.ts | 8 +- src/v1p3beta1/product_search_client.ts | 8 +- src/v1p4beta1/image_annotator_client.ts | 8 +- src/v1p4beta1/product_search_client.ts | 8 +- 222 files changed, 4 insertions(+), 43524 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1p1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p1beta1/.gitignore delete mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p1beta1/README.md delete mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p1beta1/package.json delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json delete mode 100644 owl-bot-staging/v1p1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p2beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p2beta1/.gitignore delete mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p2beta1/README.md delete mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p2beta1/package.json delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json delete mode 100644 owl-bot-staging/v1p2beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts delete mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p3beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p3beta1/.gitignore delete mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p3beta1/README.md delete mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p3beta1/package.json delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json delete mode 100644 owl-bot-staging/v1p3beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p4beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p4beta1/.gitignore delete mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p4beta1/README.md delete mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p4beta1/package.json delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json delete mode 100644 owl-bot-staging/v1p4beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto deleted file mode 100644 index 7e0d24c2..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto deleted file mode 100644 index 10464b0e..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto +++ /dev/null @@ -1,1043 +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.vision.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search.proto"; -import "google/cloud/vision/v1/text_annotation.proto"; -import "google/cloud/vision/v1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1/images:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1/files:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/images:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/files:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateImages requests. It does - // not work for AsyncBatchAnnotateImages requests. - bytes content = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - - // Left cheek center. - LEFT_CHEEK_CENTER = 35; - - // Right cheek center. - RIGHT_CHEEK_CENTER = 36; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only one - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 3; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto deleted file mode 100644 index a2a98505..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto deleted file mode 100644 index 65680d90..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto +++ /dev/null @@ -1,1022 +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.vision.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/vision/v1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or - // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are - // still supported, but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1.Product.product_category], and the - // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a - // space (" "). You can update the `display_name` later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto deleted file mode 100644 index 9c07c322..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto +++ /dev/null @@ -1,258 +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.vision.v1; - -import "google/cloud/vision/v1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more -// detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto deleted file mode 100644 index 369a1350..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 7d7ed138..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 70be298e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 528c4d1f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 2f57a691..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js deleted file mode 100644 index 1826ada2..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js deleted file mode 100644 index 9e064a95..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { - // [START vision_v1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js deleted file mode 100644 index 5c580189..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js deleted file mode 100644 index 6175cef1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js deleted file mode 100644 index 8d58541b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js deleted file mode 100644 index 5c5b8125..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js deleted file mode 100644 index 18a64743..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js deleted file mode 100644 index 27e014db..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js deleted file mode 100644 index fa80ab00..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js deleted file mode 100644 index b25fb5e6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js deleted file mode 100644 index 859e0f5a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js deleted file mode 100644 index 66a071b0..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js deleted file mode 100644 index 8fa795f6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js deleted file mode 100644 index 3e9871fc..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js deleted file mode 100644 index f7175d39..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js deleted file mode 100644 index 0dae0b9b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js deleted file mode 100644 index ad66ef6b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js deleted file mode 100644 index d8fd49f9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js deleted file mode 100644 index 26bf5ed6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json deleted file mode 100644 index def101a1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1.OutputConfig" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 67a41d87..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /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. ** - -import * as v1 from './v1'; -const ImageAnnotatorClient = v1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1.ImageAnnotatorClient; -const ProductSearchClient = v1.ProductSearchClient; -type ProductSearchClient = v1.ProductSearchClient; -export {v1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 13fb1dac..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts deleted file mode 100644 index ea2296c7..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client.ts +++ /dev/null @@ -1,921 +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/v1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. - * 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/image_annotator.batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. - * 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/image_annotator.batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - 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.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - 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.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json deleted file mode 100644 index 08f87df9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts deleted file mode 100644 index 7e03c2b8..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client.ts +++ /dev/null @@ -1,2654 +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} 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/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.create_product_set.js - * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.get_product_set.js - * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.update_product_set.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product_set.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.create_product.js - * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.get_product.js - * region_tag:vision_v1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.update_product.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.create_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.get_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.add_product_to_product_set.js - * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products.js - * region_tag:vision_v1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js - * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products_in_product_set.js - * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json deleted file mode 100644 index b7db1b90..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client_config.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts deleted file mode 100644 index 64295d79..00000000 --- a/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts +++ /dev/null @@ -1,784 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts deleted file mode 100644 index e8ec2247..00000000 --- a/owl-bot-staging/v1/test/gapic_product_search_v1.ts +++ /dev/null @@ -1,2836 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1.ProductSearchClient({ - 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 productsearchModule.v1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'vision', - filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p1beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json deleted file mode 100644 index ac8fd32c..00000000 --- a/owl-bot-staging/v1p1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto deleted file mode 100644 index 6d46d9c3..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// 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 bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto deleted file mode 100644 index 729a0fa0..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ /dev/null @@ -1,617 +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.vision.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p1beta1/geometry.proto"; -import "google/cloud/vision/v1p1beta1/text_annotation.proto"; -import "google/cloud/vision/v1p1beta1/web_detection.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p1beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } -} - -// Users describe the type of Google Cloud Vision API tasks to perform over -// images by using *Feature*s. Each Feature indicates a type of image -// detection task to perform. Features encode the Cloud Vision API -// vertical to operate on and the number of top-scoring results to return. -message Feature { - // Type of image feature. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run OCR. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run computer vision models to compute image safe-search properties. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". - string model = 3; -} - -// External image source (Google Cloud Storage image location). -message ImageSource { - // NOTE: For new code `image_uri` below is preferred. - // Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - string gcs_image_uri = 1; - - // Image URI which supports: - // 1) Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - // 2) Publicly accessible image HTTP/HTTPS URL. - // This is preferred over the legacy `gcs_image_uri` above. When both - // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location. If both `content` and `source` - // are provided for an image, `content` takes precedence and is - // used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // lat/long rectangle that specifies the location of the image. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto deleted file mode 100644 index f85cc44d..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -import "google/cloud/vision/v1p1beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width in pixels. - int32 width = 2; - - // Page height in pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto deleted file mode 100644 index c50e1ad6..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index eb0fe422..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json deleted file mode 100644 index dbece339..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p1beta1", - "version": "v1p1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts deleted file mode 100644 index 1137dce5..00000000 --- a/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; -const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -export {v1p1beta1, ImageAnnotatorClient}; -export default {v1p1beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json deleted file mode 100644 index 2dc79630..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts deleted file mode 100644 index 092acab0..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts +++ /dev/null @@ -1,373 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1p1beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p1beta1 - */ -export class ImageAnnotatorClient { - 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}; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p1beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. - * 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/v1p1beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json deleted file mode 100644 index 469fb95c..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p1beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json deleted file mode 100644 index 35609fc8..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts deleted file mode 100644 index a7fde53a..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts +++ /dev/null @@ -1,209 +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 imageannotatorModule from '../src'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1p1beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p1beta1/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: 'vision', - filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p2beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p2beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json deleted file mode 100644 index ac8fd32c..00000000 --- a/owl-bot-staging/v1p2beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto deleted file mode 100644 index e9fec20b..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto deleted file mode 100644 index 5fc3163c..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ /dev/null @@ -1,793 +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.vision.v1p2beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p2beta1/geometry.proto"; -import "google/cloud/vision/v1p2beta1/text_annotation.proto"; -import "google/cloud/vision/v1p2beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p2beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run async image detection and annotation for a list of generic files (e.g. - // PDF) which may contain multiple pages and multiple images per page. - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p2beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file on GCS. - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a GCS - // object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto deleted file mode 100644 index af568194..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -import "google/cloud/vision/v1p2beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto deleted file mode 100644 index 2decb859..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 92074c3a..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 793ec83e..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json deleted file mode 100644 index c843af75..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p2beta1", - "version": "v1p2beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts deleted file mode 100644 index 0e8fea74..00000000 --- a/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; -const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -export {v1p2beta1, ImageAnnotatorClient}; -export default {v1p2beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json deleted file mode 100644 index 116ff853..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts deleted file mode 100644 index 399a91e4..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts +++ /dev/null @@ -1,492 +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/v1p2beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p2beta1 - */ -export class ImageAnnotatorClient { - 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; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p2beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. - * 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/v1p2beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run async image detection and annotation for a list of generic files (e.g. - * PDF) which may contain multiple pages and multiple images per page. - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json deleted file mode 100644 index 367627eb..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p2beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json deleted file mode 100644 index 2b5904f9..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts deleted file mode 100644 index 770639d0..00000000 --- a/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts +++ /dev/null @@ -1,337 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p2beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p2beta1/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: 'vision', - filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p3beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p3beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1p3beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto deleted file mode 100644 index c2c524fb..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto deleted file mode 100644 index ca0b4e86..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ /dev/null @@ -1,832 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search.proto"; -import "google/cloud/vision/v1p3beta1/text_annotation.proto"; -import "google/cloud/vision/v1p3beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p3beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = - 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto deleted file mode 100644 index 86ea1a06..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1p3beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto deleted file mode 100644 index daf1d0dd..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto +++ /dev/null @@ -1,971 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. All Products and ReferenceImages in the - // ProductSet will be deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only display_name, description and labels can be updated right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - // - // Possible errors: - // - // * Returns NOT_FOUND if the product does not exist. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the reference image does not exist. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND If the Product is not found under the ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories - // "homegoods", "apparel", and "toys" are still supported, but these should - // not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 100 product_labels. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this field is 0. - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 6 columns. - // 1. image_uri - // 2, image_id - // 3. product_set_id - // 4. product_id - // 5, product_category - // 6, product_display_name - // 7, labels - // 8. bounding_poly - // - // Columns 1, 3, 4, and 5 are required, other columns are optional. A new - // ProductSet/Product with the same id will be created on the fly - // if the ProductSet/Product specified by product_set_id/product_id does not - // exist. - // - // The image_id field is optional but has to be unique if provided. If it is - // empty, we will automatically assign an unique id to the image. - // - // The product_display_name field is optional. If it is empty, a space (" ") - // is used as the place holder for the product display_name, which can - // be updated later through the realtime API. - // - // If the Product with product_id already exists, the fields - // product_display_name, product_category and labels are ignored. - // - // If a Product doesn't exist and needs to be created on the fly, the - // product_display_name field refers to - // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], - // the product_category field refers to - // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], - // and the labels field refers to [Product.labels][]. - // - // Labels (optional) should be a line containing a list of comma-separated - // key-value pairs, with the format - // "key_1=value_1,key_2=value_2,...,key_n=value_n". - // - // The bounding_poly (optional) field is used to identify one region of - // interest from the image in the same manner as CreateReferenceImage. If no - // bounding_poly is specified, the system will try to detect regions of - // interest automatically. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 20MP). - // - // Also note that at most one bounding_poly is allowed per line. If the image - // contains multiple regions of interest, the csv should contain one line per - // region of interest. - // - // The bounding_poly column should contain an even number of comma-separated - // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative - // integers should be used for absolute bounding polygons, and float values - // in [0, 1] should be used for normalized bounding polygons. - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto deleted file mode 100644 index 633e404e..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -import "google/cloud/vision/v1p3beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto deleted file mode 100644 index 205dfe65..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 900c1b0b..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 1b58eca1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Individual image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index 96b4c8ba..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js deleted file mode 100644 index ed6ac1b8..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js deleted file mode 100644 index 90879035..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js deleted file mode 100644 index 48848360..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js deleted file mode 100644 index a5872042..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js deleted file mode 100644 index 7d971bc3..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js deleted file mode 100644 index c97f2727..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js deleted file mode 100644 index c62e8ea6..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js deleted file mode 100644 index 4def76dc..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js deleted file mode 100644 index 93ee9d82..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js deleted file mode 100644 index 23698c04..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js deleted file mode 100644 index 52033c07..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js deleted file mode 100644 index 454672d1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 65bc35e2..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js deleted file mode 100644 index 9deb4e05..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index 45dcddaf..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js deleted file mode 100644 index 8d98838c..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js deleted file mode 100644 index cfecdb70..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json deleted file mode 100644 index 90042759..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p3beta1", - "version": "v1p3beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts deleted file mode 100644 index 9e656a03..00000000 --- a/owl-bot-staging/v1p3beta1/src/index.ts +++ /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. ** - -import * as v1p3beta1 from './v1p3beta1'; -const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p3beta1.ProductSearchClient; -type ProductSearchClient = v1p3beta1.ProductSearchClient; -export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json deleted file mode 100644 index 52ae14a4..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p3beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts deleted file mode 100644 index 2114aa92..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts +++ /dev/null @@ -1,671 +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/v1p3beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p3beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. - * 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/v1p3beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json deleted file mode 100644 index 75a2b706..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts deleted file mode 100644 index 2dacf41c..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts +++ /dev/null @@ -1,2538 +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} 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/v1p3beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p3beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.create_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.get_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.update_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. All Products and ReferenceImages in the - * ProductSet will be deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.create_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.get_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only display_name, description and labels can be updated right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.update_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * Possible errors: - * - * * Returns NOT_FOUND if the product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.create_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the reference image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.get_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND If the Product is not found under the ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json deleted file mode 100644 index ddc1e9ad..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts deleted file mode 100644 index 66892759..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts +++ /dev/null @@ -1,486 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p3beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts deleted file mode 100644 index b8a9d88b..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts +++ /dev/null @@ -1,2692 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p3beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p3beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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 productsearchModule.v1p3beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p3beta1/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: 'vision', - filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p4beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p4beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1p4beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto deleted file mode 100644 index d2ab72f0..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto +++ /dev/null @@ -1,60 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "CelebrityProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a celebrity recognition request. -message FaceRecognitionParams { - // The resource names for one or more - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity - // set is preloaded and can be specified as "builtin/default". If this is - // specified, the algorithm will try to match the faces detected in the input - // image to the Celebrities in the CelebritySets. - repeated string celebrity_set = 1; -} - -// A Celebrity is a group of Faces with an identity. -message Celebrity { - // The resource name of the preloaded Celebrity. Has the format - // `builtin/{mid}`. - string name = 1; - - // The Celebrity's display name. - string display_name = 2; - - // The Celebrity's description. - string description = 3; -} - -// Information about a face's identity. -message FaceRecognitionResult { - // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was - // matched to. - Celebrity celebrity = 1; - - // Recognition confidence. Range [0, 1]. - float confidence = 2; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto deleted file mode 100644 index 877fd897..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto +++ /dev/null @@ -1,70 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto deleted file mode 100644 index 0fed9eea..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ /dev/null @@ -1,966 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p4beta1/face.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search.proto"; -import "google/cloud/vision/v1p4beta1/text_annotation.proto"; -import "google/cloud/vision/v1p4beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) - returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/files:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/images:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; - - // Additional recognition information. Only computed if - // image_context.face_recognition_params is provided, **and** a match is found - // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is - // sorted in order of decreasing confidence values. - repeated FaceRecognitionResult recognition_result = 16; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for face recognition. - FaceRecognitionParams face_recognition_params = 10; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only - // one AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto deleted file mode 100644 index ebb428ac..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto +++ /dev/null @@ -1,127 +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.vision.v1p4beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a - // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for - // similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto deleted file mode 100644 index df7bc7a3..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto +++ /dev/null @@ -1,1039 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of -// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of -// [Product][google.cloud.vision.v1p4beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of -// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, -// named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) - returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = - "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. - // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The - // legacy categories "homegoods", "apparel", and "toys" are still supported, - // but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference - // image. If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference - // image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this - // ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], - // and the `labels` column refers to - // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] - // field for the product to a space (" "). You can update the `display_name` - // later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto deleted file mode 100644 index 233c4c68..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto +++ /dev/null @@ -1,260 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto deleted file mode 100644 index 7d716570..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto +++ /dev/null @@ -1,106 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 199be36a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 8cb5197f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 2fe101f3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index f6aaa34e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index c6ef04f0..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js deleted file mode 100644 index 60ec6540..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js deleted file mode 100644 index ea4c348b..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js deleted file mode 100644 index bb6709c3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, referenceImage) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference - * image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js deleted file mode 100644 index 63f362dc..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js deleted file mode 100644 index 72ac7fec..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js deleted file mode 100644 index 92f9f39c..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js deleted file mode 100644 index 80db0f5a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js deleted file mode 100644 index acba73c5..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js deleted file mode 100644 index 5dc13d64..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js deleted file mode 100644 index 3a422698..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js deleted file mode 100644 index 81e409fa..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js deleted file mode 100644 index 8b67070e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 869b118f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js deleted file mode 100644 index 637c1f8a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js deleted file mode 100644 index 5dd66449..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index af9e9c14..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,71 +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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this - * ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js deleted file mode 100644 index 3c8d60bb..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js deleted file mode 100644 index 6ceb8322..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json deleted file mode 100644 index 65c6af72..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json +++ /dev/null @@ -1,1027 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p4beta1", - "version": "v1p4beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1p4beta1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts deleted file mode 100644 index 464f947a..00000000 --- a/owl-bot-staging/v1p4beta1/src/index.ts +++ /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. ** - -import * as v1p4beta1 from './v1p4beta1'; -const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p4beta1.ProductSearchClient; -type ProductSearchClient = v1p4beta1.ProductSearchClient; -export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json deleted file mode 100644 index 8338e641..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p4beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts deleted file mode 100644 index cb620c40..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts +++ /dev/null @@ -1,848 +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/v1p4beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p4beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json deleted file mode 100644 index e068ba98..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts deleted file mode 100644 index 6e9bcc4b..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts +++ /dev/null @@ -1,2661 +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} 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/v1p4beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of - * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, - * named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p4beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.create_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.get_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.update_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.create_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.get_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.update_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference - * image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.create_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.get_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this - * ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json deleted file mode 100644 index 518529b7..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts deleted file mode 100644 index 5fb3c9d9..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts +++ /dev/null @@ -1,670 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p4beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts deleted file mode 100644 index 5a2d84cc..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts +++ /dev/null @@ -1,2836 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p4beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p4beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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 productsearchModule.v1p4beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p4beta1/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: 'vision', - filename: './vision.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/src/v1p3beta1/image_annotator_client.ts b/src/v1p3beta1/image_annotator_client.ts index 8f93f243..7f0e5c86 100644 --- a/src/v1p3beta1/image_annotator_client.ts +++ b/src/v1p3beta1/image_annotator_client.ts @@ -199,13 +199,7 @@ export class ImageAnnotatorClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) diff --git a/src/v1p3beta1/product_search_client.ts b/src/v1p3beta1/product_search_client.ts index 7fd4bc1d..72350986 100644 --- a/src/v1p3beta1/product_search_client.ts +++ b/src/v1p3beta1/product_search_client.ts @@ -241,13 +241,7 @@ export class ProductSearchClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) diff --git a/src/v1p4beta1/image_annotator_client.ts b/src/v1p4beta1/image_annotator_client.ts index 822f3f8b..d8d335af 100644 --- a/src/v1p4beta1/image_annotator_client.ts +++ b/src/v1p4beta1/image_annotator_client.ts @@ -199,13 +199,7 @@ export class ImageAnnotatorClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) diff --git a/src/v1p4beta1/product_search_client.ts b/src/v1p4beta1/product_search_client.ts index 6f79774d..64850bd1 100644 --- a/src/v1p4beta1/product_search_client.ts +++ b/src/v1p4beta1/product_search_client.ts @@ -245,13 +245,7 @@ export class ProductSearchClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) From 8803e219c4ec920decb691b0957f4a0660b85cce Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Sep 2022 19:49:27 +0000 Subject: [PATCH 3/9] docs: update comments for image annotator OCR models PiperOrigin-RevId: 474070246 Source-Link: https://github.com/googleapis/googleapis/commit/346e2f2a106ed0ff8863b11a3b1ec32cd40b9cf1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/50b34515fa89525989021be4b6989d49059d8d26 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTBiMzQ1MTVmYTg5NTI1OTg5MDIxYmU0YjY5ODlkNDkwNTlkOGQyNiJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 65 + .../google/cloud/vision/v1/geometry.proto | 68 + .../cloud/vision/v1/image_annotator.proto | 1044 ++++++ .../cloud/vision/v1/product_search.proto | 124 + .../vision/v1/product_search_service.proto | 1022 ++++++ .../cloud/vision/v1/text_annotation.proto | 258 ++ .../cloud/vision/v1/web_detection.proto | 104 + ...ge_annotator.async_batch_annotate_files.js | 73 + ...e_annotator.async_batch_annotate_images.js | 78 + .../image_annotator.batch_annotate_files.js | 73 + .../image_annotator.batch_annotate_images.js | 72 + ...oduct_search.add_product_to_product_set.js | 70 + .../v1/product_search.create_product.js | 75 + .../v1/product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../v1/product_search.delete_product.js | 63 + .../v1/product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1/product_search.get_product.js | 63 + .../v1/product_search.get_product_set.js | 63 + .../v1/product_search.get_reference_image.js | 63 + .../v1/product_search.import_product_sets.js | 68 + .../v1/product_search.list_product_sets.js | 72 + .../v1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../v1/product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 70 + .../v1/product_search.update_product.js | 70 + .../v1/product_search.update_product_set.js | 68 + ...ippet_metadata.google.cloud.vision.v1.json | 1043 ++++++ owl-bot-staging/v1/src/index.ts | 27 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 ++ .../v1/src/v1/image_annotator_client.ts | 921 ++++++ .../src/v1/image_annotator_client_config.json | 46 + .../v1/src/v1/image_annotator_proto_list.json | 8 + owl-bot-staging/v1/src/v1/index.ts | 20 + .../v1/src/v1/product_search_client.ts | 2654 +++++++++++++++ .../src/v1/product_search_client_config.json | 121 + .../v1/src/v1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_image_annotator_v1.ts | 784 +++++ .../v1/test/gapic_product_search_v1.ts | 2836 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1p1beta1/.eslintignore | 7 + owl-bot-staging/v1p1beta1/.eslintrc.json | 3 + owl-bot-staging/v1p1beta1/.gitignore | 14 + owl-bot-staging/v1p1beta1/.jsdoc.js | 55 + owl-bot-staging/v1p1beta1/.mocharc.js | 33 + owl-bot-staging/v1p1beta1/.prettierrc.js | 22 + owl-bot-staging/v1p1beta1/README.md | 1 + .../v1p1beta1/linkinator.config.json | 16 + owl-bot-staging/v1p1beta1/package.json | 64 + .../cloud/vision/v1p1beta1/geometry.proto | 53 + .../vision/v1p1beta1/image_annotator.proto | 618 ++++ .../vision/v1p1beta1/text_annotation.proto | 251 ++ .../vision/v1p1beta1/web_detection.proto | 103 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p1beta1.json | 55 + owl-bot-staging/v1p1beta1/src/index.ts | 25 + .../src/v1p1beta1/gapic_metadata.json | 33 + .../src/v1p1beta1/image_annotator_client.ts | 373 +++ .../image_annotator_client_config.json | 31 + .../v1p1beta1/image_annotator_proto_list.json | 6 + .../v1p1beta1/src/v1p1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p1beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p1beta1.ts | 209 ++ owl-bot-staging/v1p1beta1/tsconfig.json | 19 + owl-bot-staging/v1p1beta1/webpack.config.js | 64 + owl-bot-staging/v1p2beta1/.eslintignore | 7 + owl-bot-staging/v1p2beta1/.eslintrc.json | 3 + owl-bot-staging/v1p2beta1/.gitignore | 14 + owl-bot-staging/v1p2beta1/.jsdoc.js | 55 + owl-bot-staging/v1p2beta1/.mocharc.js | 33 + owl-bot-staging/v1p2beta1/.prettierrc.js | 22 + owl-bot-staging/v1p2beta1/README.md | 1 + .../v1p2beta1/linkinator.config.json | 16 + owl-bot-staging/v1p2beta1/package.json | 64 + .../cloud/vision/v1p2beta1/geometry.proto | 67 + .../vision/v1p2beta1/image_annotator.proto | 794 +++++ .../vision/v1p2beta1/text_annotation.proto | 258 ++ .../vision/v1p2beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p2beta1.json | 95 + owl-bot-staging/v1p2beta1/src/index.ts | 25 + .../src/v1p2beta1/gapic_metadata.json | 43 + .../src/v1p2beta1/image_annotator_client.ts | 492 +++ .../image_annotator_client_config.json | 36 + .../v1p2beta1/image_annotator_proto_list.json | 6 + .../v1p2beta1/src/v1p2beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p2beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p2beta1.ts | 337 ++ owl-bot-staging/v1p2beta1/tsconfig.json | 19 + owl-bot-staging/v1p2beta1/webpack.config.js | 64 + owl-bot-staging/v1p3beta1/.eslintignore | 7 + owl-bot-staging/v1p3beta1/.eslintrc.json | 3 + owl-bot-staging/v1p3beta1/.gitignore | 14 + owl-bot-staging/v1p3beta1/.jsdoc.js | 55 + owl-bot-staging/v1p3beta1/.mocharc.js | 33 + owl-bot-staging/v1p3beta1/.prettierrc.js | 22 + owl-bot-staging/v1p3beta1/README.md | 1 + .../v1p3beta1/linkinator.config.json | 16 + owl-bot-staging/v1p3beta1/package.json | 65 + .../cloud/vision/v1p3beta1/geometry.proto | 68 + .../vision/v1p3beta1/image_annotator.proto | 833 +++++ .../vision/v1p3beta1/product_search.proto | 124 + .../v1p3beta1/product_search_service.proto | 971 ++++++ .../vision/v1p3beta1/text_annotation.proto | 258 ++ .../vision/v1p3beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p3beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p3beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + ..._search.remove_product_from_product_set.js | 70 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p3beta1.json | 891 ++++++ owl-bot-staging/v1p3beta1/src/index.ts | 27 + .../src/v1p3beta1/gapic_metadata.json | 253 ++ .../src/v1p3beta1/image_annotator_client.ts | 671 ++++ .../image_annotator_client_config.json | 36 + .../v1p3beta1/image_annotator_proto_list.json | 8 + .../v1p3beta1/src/v1p3beta1/index.ts | 20 + .../src/v1p3beta1/product_search_client.ts | 2538 +++++++++++++++ .../product_search_client_config.json | 116 + .../v1p3beta1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p3beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p3beta1.ts | 486 +++ .../test/gapic_product_search_v1p3beta1.ts | 2692 ++++++++++++++++ owl-bot-staging/v1p3beta1/tsconfig.json | 19 + owl-bot-staging/v1p3beta1/webpack.config.js | 64 + owl-bot-staging/v1p4beta1/.eslintignore | 7 + owl-bot-staging/v1p4beta1/.eslintrc.json | 3 + owl-bot-staging/v1p4beta1/.gitignore | 14 + owl-bot-staging/v1p4beta1/.jsdoc.js | 55 + owl-bot-staging/v1p4beta1/.mocharc.js | 33 + owl-bot-staging/v1p4beta1/.prettierrc.js | 22 + owl-bot-staging/v1p4beta1/README.md | 1 + .../v1p4beta1/linkinator.config.json | 16 + owl-bot-staging/v1p4beta1/package.json | 65 + .../google/cloud/vision/v1p4beta1/face.proto | 60 + .../cloud/vision/v1p4beta1/geometry.proto | 70 + .../vision/v1p4beta1/image_annotator.proto | 967 ++++++ .../vision/v1p4beta1/product_search.proto | 127 + .../v1p4beta1/product_search_service.proto | 1039 ++++++ .../vision/v1p4beta1/text_annotation.proto | 260 ++ .../vision/v1p4beta1/web_detection.proto | 106 + ...ge_annotator.async_batch_annotate_files.js | 62 + ...e_annotator.async_batch_annotate_images.js | 67 + .../image_annotator.batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 77 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p4beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p4beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 71 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ++++++ owl-bot-staging/v1p4beta1/src/index.ts | 27 + .../src/v1p4beta1/gapic_metadata.json | 283 ++ .../src/v1p4beta1/image_annotator_client.ts | 848 +++++ .../image_annotator_client_config.json | 46 + .../v1p4beta1/image_annotator_proto_list.json | 9 + .../v1p4beta1/src/v1p4beta1/index.ts | 20 + .../src/v1p4beta1/product_search_client.ts | 2661 ++++++++++++++++ .../product_search_client_config.json | 120 + .../v1p4beta1/product_search_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p4beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p4beta1.ts | 670 ++++ .../test/gapic_product_search_v1p4beta1.ts | 2836 +++++++++++++++++ owl-bot-staging/v1p4beta1/tsconfig.json | 19 + owl-bot-staging/v1p4beta1/webpack.config.js | 64 + 218 files changed, 43501 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1p1beta1/.eslintignore create mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p1beta1/.gitignore create mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p1beta1/README.md create mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p1beta1/package.json create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json create mode 100644 owl-bot-staging/v1p1beta1/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p2beta1/.eslintignore create mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p2beta1/.gitignore create mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p2beta1/README.md create mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p2beta1/package.json create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json create mode 100644 owl-bot-staging/v1p2beta1/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts create mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p3beta1/.eslintignore create mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p3beta1/.gitignore create mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p3beta1/README.md create mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p3beta1/package.json create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json create mode 100644 owl-bot-staging/v1p3beta1/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p4beta1/.eslintignore create mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p4beta1/.gitignore create mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p4beta1/README.md create mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p4beta1/package.json create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json create mode 100644 owl-bot-staging/v1p4beta1/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto new file mode 100644 index 00000000..7e0d24c2 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto new file mode 100644 index 00000000..6fed6112 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto @@ -0,0 +1,1044 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search.proto"; +import "google/cloud/vision/v1/text_annotation.proto"; +import "google/cloud/vision/v1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1/images:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1/files:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/images:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/files:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateImages requests. It does + // not work for AsyncBatchAnnotateImages requests. + bytes content = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + + // Left cheek center. + LEFT_CHEEK_CENTER = 35; + + // Right cheek center. + RIGHT_CHEEK_CENTER = 36; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 3; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto new file mode 100644 index 00000000..a2a98505 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto new file mode 100644 index 00000000..65680d90 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto @@ -0,0 +1,1022 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.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/vision/v1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or + // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are + // still supported, but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1.Product.product_category], and the + // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a + // space (" "). You can update the `display_name` later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto new file mode 100644 index 00000000..9c07c322 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/cloud/vision/v1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more +// detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto new file mode 100644 index 00000000..369a1350 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..7d7ed138 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..70be298e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..528c4d1f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..2f57a691 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..1826ada2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js new file mode 100644 index 00000000..9e064a95 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { + // [START vision_v1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js new file mode 100644 index 00000000..5c580189 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js new file mode 100644 index 00000000..6175cef1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js new file mode 100644 index 00000000..8d58541b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js new file mode 100644 index 00000000..5c5b8125 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js new file mode 100644 index 00000000..18a64743 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js new file mode 100644 index 00000000..27e014db --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js new file mode 100644 index 00000000..fa80ab00 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js new file mode 100644 index 00000000..b25fb5e6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js new file mode 100644 index 00000000..859e0f5a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js new file mode 100644 index 00000000..66a071b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js new file mode 100644 index 00000000..8fa795f6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..3e9871fc --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js new file mode 100644 index 00000000..f7175d39 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js new file mode 100644 index 00000000..0dae0b9b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..ad66ef6b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js new file mode 100644 index 00000000..d8fd49f9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js new file mode 100644 index 00000000..26bf5ed6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json new file mode 100644 index 00000000..def101a1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json @@ -0,0 +1,1043 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1.OutputConfig" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..67a41d87 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ImageAnnotatorClient = v1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1.ImageAnnotatorClient; +const ProductSearchClient = v1.ProductSearchClient; +type ProductSearchClient = v1.ProductSearchClient; +export {v1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..13fb1dac --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts new file mode 100644 index 00000000..ea2296c7 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client.ts @@ -0,0 +1,921 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. + * 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/image_annotator.batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * 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/image_annotator.batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + 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.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + 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.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json new file mode 100644 index 00000000..08f87df9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts new file mode 100644 index 00000000..7e03c2b8 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client.ts @@ -0,0 +1,2654 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.create_product_set.js + * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.get_product_set.js + * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.update_product_set.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product_set.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.create_product.js + * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.get_product.js + * region_tag:vision_v1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.update_product.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.create_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.get_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.add_product_to_product_set.js + * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products.js + * region_tag:vision_v1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js + * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products_in_product_set.js + * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json new file mode 100644 index 00000000..b7db1b90 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client_config.json @@ -0,0 +1,121 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts new file mode 100644 index 00000000..64295d79 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts @@ -0,0 +1,784 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts new file mode 100644 index 00000000..e8ec2247 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_product_search_v1.ts @@ -0,0 +1,2836 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1.ProductSearchClient({ + 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 productsearchModule.v1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'vision', + filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json new file mode 100644 index 00000000..ac8fd32c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto new file mode 100644 index 00000000..6d46d9c3 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// 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 bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto new file mode 100644 index 00000000..f66ad504 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -0,0 +1,618 @@ +// 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.vision.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p1beta1/geometry.proto"; +import "google/cloud/vision/v1p1beta1/text_annotation.proto"; +import "google/cloud/vision/v1p1beta1/web_detection.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p1beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } +} + +// Users describe the type of Google Cloud Vision API tasks to perform over +// images by using *Feature*s. Each Feature indicates a type of image +// detection task to perform. Features encode the Cloud Vision API +// vertical to operate on and the number of top-scoring results to return. +message Feature { + // Type of image feature. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run OCR. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run computer vision models to compute image safe-search properties. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage image location). +message ImageSource { + // NOTE: For new code `image_uri` below is preferred. + // Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + string gcs_image_uri = 1; + + // Image URI which supports: + // 1) Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + // 2) Publicly accessible image HTTP/HTTPS URL. + // This is preferred over the legacy `gcs_image_uri` above. When both + // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location. If both `content` and `source` + // are provided for an image, `content` takes precedence and is + // used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // lat/long rectangle that specifies the location of the image. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto new file mode 100644 index 00000000..f85cc44d --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto @@ -0,0 +1,251 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +import "google/cloud/vision/v1p1beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width in pixels. + int32 width = 2; + + // Page height in pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto new file mode 100644 index 00000000..c50e1ad6 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..eb0fe422 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json new file mode 100644 index 00000000..dbece339 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p1beta1", + "version": "v1p1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts new file mode 100644 index 00000000..1137dce5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; +const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +export {v1p1beta1, ImageAnnotatorClient}; +export default {v1p1beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json new file mode 100644 index 00000000..2dc79630 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts new file mode 100644 index 00000000..092acab0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p1beta1 + */ +export class ImageAnnotatorClient { + 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}; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p1beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. + * 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/v1p1beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json new file mode 100644 index 00000000..469fb95c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.vision.v1p1beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..35609fc8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts new file mode 100644 index 00000000..a7fde53a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts @@ -0,0 +1,209 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1p1beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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: 'vision', + filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json new file mode 100644 index 00000000..ac8fd32c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto new file mode 100644 index 00000000..e9fec20b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto @@ -0,0 +1,67 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto new file mode 100644 index 00000000..264462d4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -0,0 +1,794 @@ +// 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.vision.v1p2beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p2beta1/geometry.proto"; +import "google/cloud/vision/v1p2beta1/text_annotation.proto"; +import "google/cloud/vision/v1p2beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p2beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run async image detection and annotation for a list of generic files (e.g. + // PDF) which may contain multiple pages and multiple images per page. + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p2beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file on GCS. + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a GCS + // object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto new file mode 100644 index 00000000..af568194 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +import "google/cloud/vision/v1p2beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto new file mode 100644 index 00000000..2decb859 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..92074c3a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..793ec83e --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json new file mode 100644 index 00000000..c843af75 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json @@ -0,0 +1,95 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p2beta1", + "version": "v1p2beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts new file mode 100644 index 00000000..0e8fea74 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; +const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +export {v1p2beta1, ImageAnnotatorClient}; +export default {v1p2beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json new file mode 100644 index 00000000..116ff853 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts new file mode 100644 index 00000000..399a91e4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts @@ -0,0 +1,492 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p2beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p2beta1 + */ +export class ImageAnnotatorClient { + 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; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p2beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. + * 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/v1p2beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run async image detection and annotation for a list of generic files (e.g. + * PDF) which may contain multiple pages and multiple images per page. + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json new file mode 100644 index 00000000..367627eb --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p2beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..2b5904f9 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts new file mode 100644 index 00000000..770639d0 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts @@ -0,0 +1,337 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p2beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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: 'vision', + filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p3beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1p3beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto new file mode 100644 index 00000000..c2c524fb --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto new file mode 100644 index 00000000..ebab14a6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -0,0 +1,833 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search.proto"; +import "google/cloud/vision/v1p3beta1/text_annotation.proto"; +import "google/cloud/vision/v1p3beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p3beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = + 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto new file mode 100644 index 00000000..86ea1a06 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto new file mode 100644 index 00000000..daf1d0dd --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto @@ -0,0 +1,971 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. All Products and ReferenceImages in the + // ProductSet will be deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only display_name, description and labels can be updated right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + // + // Possible errors: + // + // * Returns NOT_FOUND if the product does not exist. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the reference image does not exist. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND If the Product is not found under the ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories + // "homegoods", "apparel", and "toys" are still supported, but these should + // not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 100 product_labels. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this field is 0. + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 6 columns. + // 1. image_uri + // 2, image_id + // 3. product_set_id + // 4. product_id + // 5, product_category + // 6, product_display_name + // 7, labels + // 8. bounding_poly + // + // Columns 1, 3, 4, and 5 are required, other columns are optional. A new + // ProductSet/Product with the same id will be created on the fly + // if the ProductSet/Product specified by product_set_id/product_id does not + // exist. + // + // The image_id field is optional but has to be unique if provided. If it is + // empty, we will automatically assign an unique id to the image. + // + // The product_display_name field is optional. If it is empty, a space (" ") + // is used as the place holder for the product display_name, which can + // be updated later through the realtime API. + // + // If the Product with product_id already exists, the fields + // product_display_name, product_category and labels are ignored. + // + // If a Product doesn't exist and needs to be created on the fly, the + // product_display_name field refers to + // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], + // the product_category field refers to + // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], + // and the labels field refers to [Product.labels][]. + // + // Labels (optional) should be a line containing a list of comma-separated + // key-value pairs, with the format + // "key_1=value_1,key_2=value_2,...,key_n=value_n". + // + // The bounding_poly (optional) field is used to identify one region of + // interest from the image in the same manner as CreateReferenceImage. If no + // bounding_poly is specified, the system will try to detect regions of + // interest automatically. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 20MP). + // + // Also note that at most one bounding_poly is allowed per line. If the image + // contains multiple regions of interest, the csv should contain one line per + // region of interest. + // + // The bounding_poly column should contain an even number of comma-separated + // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative + // integers should be used for absolute bounding polygons, and float values + // in [0, 1] should be used for normalized bounding polygons. + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto new file mode 100644 index 00000000..633e404e --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/cloud/vision/v1p3beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto new file mode 100644 index 00000000..205dfe65 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..900c1b0b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..1b58eca1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Individual image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..96b4c8ba --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js new file mode 100644 index 00000000..ed6ac1b8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js new file mode 100644 index 00000000..90879035 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..48848360 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js new file mode 100644 index 00000000..a5872042 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..7d971bc3 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..c97f2727 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js new file mode 100644 index 00000000..c62e8ea6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js new file mode 100644 index 00000000..4def76dc --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..93ee9d82 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..23698c04 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..52033c07 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js new file mode 100644 index 00000000..454672d1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..65bc35e2 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..9deb4e05 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..45dcddaf --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js new file mode 100644 index 00000000..8d98838c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js new file mode 100644 index 00000000..cfecdb70 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json new file mode 100644 index 00000000..90042759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json @@ -0,0 +1,891 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p3beta1", + "version": "v1p3beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts new file mode 100644 index 00000000..9e656a03 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p3beta1 from './v1p3beta1'; +const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p3beta1.ProductSearchClient; +type ProductSearchClient = v1p3beta1.ProductSearchClient; +export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json new file mode 100644 index 00000000..52ae14a4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json @@ -0,0 +1,253 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p3beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts new file mode 100644 index 00000000..2114aa92 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts @@ -0,0 +1,671 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p3beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p3beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. + * 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/v1p3beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json new file mode 100644 index 00000000..75a2b706 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts new file mode 100644 index 00000000..2dacf41c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts @@ -0,0 +1,2538 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p3beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p3beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.create_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.get_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.update_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. All Products and ReferenceImages in the + * ProductSet will be deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.create_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.get_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only display_name, description and labels can be updated right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.update_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * Possible errors: + * + * * Returns NOT_FOUND if the product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.create_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the reference image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.get_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND If the Product is not found under the ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json new file mode 100644 index 00000000..ddc1e9ad --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json @@ -0,0 +1,116 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts new file mode 100644 index 00000000..66892759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts @@ -0,0 +1,486 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p3beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts new file mode 100644 index 00000000..b8a9d88b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts @@ -0,0 +1,2692 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p3beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p3beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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 productsearchModule.v1p3beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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: 'vision', + filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json new file mode 100644 index 00000000..5ccecd9d --- /dev/null +++ b/owl-bot-staging/v1p4beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.3.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.56", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.2", + "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.2", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto new file mode 100644 index 00000000..d2ab72f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto @@ -0,0 +1,60 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "CelebrityProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a celebrity recognition request. +message FaceRecognitionParams { + // The resource names for one or more + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity + // set is preloaded and can be specified as "builtin/default". If this is + // specified, the algorithm will try to match the faces detected in the input + // image to the Celebrities in the CelebritySets. + repeated string celebrity_set = 1; +} + +// A Celebrity is a group of Faces with an identity. +message Celebrity { + // The resource name of the preloaded Celebrity. Has the format + // `builtin/{mid}`. + string name = 1; + + // The Celebrity's display name. + string display_name = 2; + + // The Celebrity's description. + string description = 3; +} + +// Information about a face's identity. +message FaceRecognitionResult { + // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was + // matched to. + Celebrity celebrity = 1; + + // Recognition confidence. Range [0, 1]. + float confidence = 2; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto new file mode 100644 index 00000000..877fd897 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto @@ -0,0 +1,70 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto new file mode 100644 index 00000000..cc783697 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -0,0 +1,967 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p4beta1/face.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search.proto"; +import "google/cloud/vision/v1p4beta1/text_annotation.proto"; +import "google/cloud/vision/v1p4beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) + returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/files:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/images:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; + + // Additional recognition information. Only computed if + // image_context.face_recognition_params is provided, **and** a match is found + // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is + // sorted in order of decreasing confidence values. + repeated FaceRecognitionResult recognition_result = 16; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for face recognition. + FaceRecognitionParams face_recognition_params = 10; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only + // one AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto new file mode 100644 index 00000000..ebb428ac --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto @@ -0,0 +1,127 @@ +// 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.vision.v1p4beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a + // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for + // similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto new file mode 100644 index 00000000..df7bc7a3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto @@ -0,0 +1,1039 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of +// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of +// [Product][google.cloud.vision.v1p4beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of +// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, +// named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) + returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = + "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. + // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The + // legacy categories "homegoods", "apparel", and "toys" are still supported, + // but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference + // image. If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference + // image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this + // ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], + // and the `labels` column refers to + // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] + // field for the product to a space (" "). You can update the `display_name` + // later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto new file mode 100644 index 00000000..233c4c68 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto @@ -0,0 +1,260 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto new file mode 100644 index 00000000..7d716570 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto @@ -0,0 +1,106 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..199be36a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..8cb5197f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..2fe101f3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..f6aaa34e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..c6ef04f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js new file mode 100644 index 00000000..60ec6540 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js new file mode 100644 index 00000000..ea4c348b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..bb6709c3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference + * image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js new file mode 100644 index 00000000..63f362dc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..72ac7fec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..92f9f39c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js new file mode 100644 index 00000000..80db0f5a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js new file mode 100644 index 00000000..acba73c5 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..5dc13d64 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..3a422698 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..81e409fa --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js new file mode 100644 index 00000000..8b67070e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..869b118f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..637c1f8a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js new file mode 100644 index 00000000..5dd66449 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..af9e9c14 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this + * ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js new file mode 100644 index 00000000..3c8d60bb --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js new file mode 100644 index 00000000..6ceb8322 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json new file mode 100644 index 00000000..65c6af72 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json @@ -0,0 +1,1027 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p4beta1", + "version": "v1p4beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1p4beta1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts new file mode 100644 index 00000000..464f947a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p4beta1 from './v1p4beta1'; +const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p4beta1.ProductSearchClient; +type ProductSearchClient = v1p4beta1.ProductSearchClient; +export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json new file mode 100644 index 00000000..8338e641 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p4beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts new file mode 100644 index 00000000..cb620c40 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts @@ -0,0 +1,848 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p4beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p4beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json new file mode 100644 index 00000000..e068ba98 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts new file mode 100644 index 00000000..6e9bcc4b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts @@ -0,0 +1,2661 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p4beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of + * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, + * named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p4beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.create_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.get_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.update_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.create_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.get_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.update_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference + * image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.create_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.get_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this + * ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name || '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json new file mode 100644 index 00000000..518529b7 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json @@ -0,0 +1,120 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts new file mode 100644 index 00000000..5fb3c9d9 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts @@ -0,0 +1,670 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p4beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts new file mode 100644 index 00000000..5a2d84cc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts @@ -0,0 +1,2836 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p4beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p4beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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 productsearchModule.v1p4beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + assert((client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + assert((client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedHeaderRequestParams = "product_set.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + assert((client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); + request.productSet = {}; + request.productSet.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + assert((client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + assert((client.innerApiCalls.createProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + assert((client.innerApiCalls.getProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedHeaderRequestParams = "product.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + assert((client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); + request.product = {}; + request.product.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + assert((client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + assert((client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + assert((client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + assert((client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + assert((client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + assert((client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert.strictEqual( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + assert((client.innerApiCalls.listProducts as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert.strictEqual( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + assert((client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + assert((client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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: 'vision', + filename: './vision.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 24054cd5f067611cedc25209fd3dbab06a025791 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Sep 2022 19:52:08 +0000 Subject: [PATCH 4/9] =?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 --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 65 - .../google/cloud/vision/v1/geometry.proto | 68 - .../cloud/vision/v1/image_annotator.proto | 1044 ------ .../cloud/vision/v1/product_search.proto | 124 - .../vision/v1/product_search_service.proto | 1022 ------ .../cloud/vision/v1/text_annotation.proto | 258 -- .../cloud/vision/v1/web_detection.proto | 104 - ...ge_annotator.async_batch_annotate_files.js | 73 - ...e_annotator.async_batch_annotate_images.js | 78 - .../image_annotator.batch_annotate_files.js | 73 - .../image_annotator.batch_annotate_images.js | 72 - ...oduct_search.add_product_to_product_set.js | 70 - .../v1/product_search.create_product.js | 75 - .../v1/product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../v1/product_search.delete_product.js | 63 - .../v1/product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1/product_search.get_product.js | 63 - .../v1/product_search.get_product_set.js | 63 - .../v1/product_search.get_reference_image.js | 63 - .../v1/product_search.import_product_sets.js | 68 - .../v1/product_search.list_product_sets.js | 72 - .../v1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../v1/product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 70 - .../v1/product_search.update_product.js | 70 - .../v1/product_search.update_product_set.js | 68 - ...ippet_metadata.google.cloud.vision.v1.json | 1043 ------ owl-bot-staging/v1/src/index.ts | 27 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 -- .../v1/src/v1/image_annotator_client.ts | 921 ------ .../src/v1/image_annotator_client_config.json | 46 - .../v1/src/v1/image_annotator_proto_list.json | 8 - owl-bot-staging/v1/src/v1/index.ts | 20 - .../v1/src/v1/product_search_client.ts | 2654 --------------- .../src/v1/product_search_client_config.json | 121 - .../v1/src/v1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_image_annotator_v1.ts | 784 ----- .../v1/test/gapic_product_search_v1.ts | 2836 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1p1beta1/.eslintignore | 7 - owl-bot-staging/v1p1beta1/.eslintrc.json | 3 - owl-bot-staging/v1p1beta1/.gitignore | 14 - owl-bot-staging/v1p1beta1/.jsdoc.js | 55 - owl-bot-staging/v1p1beta1/.mocharc.js | 33 - owl-bot-staging/v1p1beta1/.prettierrc.js | 22 - owl-bot-staging/v1p1beta1/README.md | 1 - .../v1p1beta1/linkinator.config.json | 16 - owl-bot-staging/v1p1beta1/package.json | 64 - .../cloud/vision/v1p1beta1/geometry.proto | 53 - .../vision/v1p1beta1/image_annotator.proto | 618 ---- .../vision/v1p1beta1/text_annotation.proto | 251 -- .../vision/v1p1beta1/web_detection.proto | 103 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p1beta1.json | 55 - owl-bot-staging/v1p1beta1/src/index.ts | 25 - .../src/v1p1beta1/gapic_metadata.json | 33 - .../src/v1p1beta1/image_annotator_client.ts | 373 --- .../image_annotator_client_config.json | 31 - .../v1p1beta1/image_annotator_proto_list.json | 6 - .../v1p1beta1/src/v1p1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p1beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p1beta1.ts | 209 -- owl-bot-staging/v1p1beta1/tsconfig.json | 19 - owl-bot-staging/v1p1beta1/webpack.config.js | 64 - owl-bot-staging/v1p2beta1/.eslintignore | 7 - owl-bot-staging/v1p2beta1/.eslintrc.json | 3 - owl-bot-staging/v1p2beta1/.gitignore | 14 - owl-bot-staging/v1p2beta1/.jsdoc.js | 55 - owl-bot-staging/v1p2beta1/.mocharc.js | 33 - owl-bot-staging/v1p2beta1/.prettierrc.js | 22 - owl-bot-staging/v1p2beta1/README.md | 1 - .../v1p2beta1/linkinator.config.json | 16 - owl-bot-staging/v1p2beta1/package.json | 64 - .../cloud/vision/v1p2beta1/geometry.proto | 67 - .../vision/v1p2beta1/image_annotator.proto | 794 ----- .../vision/v1p2beta1/text_annotation.proto | 258 -- .../vision/v1p2beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p2beta1.json | 95 - owl-bot-staging/v1p2beta1/src/index.ts | 25 - .../src/v1p2beta1/gapic_metadata.json | 43 - .../src/v1p2beta1/image_annotator_client.ts | 492 --- .../image_annotator_client_config.json | 36 - .../v1p2beta1/image_annotator_proto_list.json | 6 - .../v1p2beta1/src/v1p2beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p2beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p2beta1.ts | 337 -- owl-bot-staging/v1p2beta1/tsconfig.json | 19 - owl-bot-staging/v1p2beta1/webpack.config.js | 64 - owl-bot-staging/v1p3beta1/.eslintignore | 7 - owl-bot-staging/v1p3beta1/.eslintrc.json | 3 - owl-bot-staging/v1p3beta1/.gitignore | 14 - owl-bot-staging/v1p3beta1/.jsdoc.js | 55 - owl-bot-staging/v1p3beta1/.mocharc.js | 33 - owl-bot-staging/v1p3beta1/.prettierrc.js | 22 - owl-bot-staging/v1p3beta1/README.md | 1 - .../v1p3beta1/linkinator.config.json | 16 - owl-bot-staging/v1p3beta1/package.json | 65 - .../cloud/vision/v1p3beta1/geometry.proto | 68 - .../vision/v1p3beta1/image_annotator.proto | 833 ----- .../vision/v1p3beta1/product_search.proto | 124 - .../v1p3beta1/product_search_service.proto | 971 ------ .../vision/v1p3beta1/text_annotation.proto | 258 -- .../vision/v1p3beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p3beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p3beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - ..._search.remove_product_from_product_set.js | 70 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p3beta1.json | 891 ------ owl-bot-staging/v1p3beta1/src/index.ts | 27 - .../src/v1p3beta1/gapic_metadata.json | 253 -- .../src/v1p3beta1/image_annotator_client.ts | 671 ---- .../image_annotator_client_config.json | 36 - .../v1p3beta1/image_annotator_proto_list.json | 8 - .../v1p3beta1/src/v1p3beta1/index.ts | 20 - .../src/v1p3beta1/product_search_client.ts | 2538 --------------- .../product_search_client_config.json | 116 - .../v1p3beta1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p3beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p3beta1.ts | 486 --- .../test/gapic_product_search_v1p3beta1.ts | 2692 ---------------- owl-bot-staging/v1p3beta1/tsconfig.json | 19 - owl-bot-staging/v1p3beta1/webpack.config.js | 64 - owl-bot-staging/v1p4beta1/.eslintignore | 7 - owl-bot-staging/v1p4beta1/.eslintrc.json | 3 - owl-bot-staging/v1p4beta1/.gitignore | 14 - owl-bot-staging/v1p4beta1/.jsdoc.js | 55 - owl-bot-staging/v1p4beta1/.mocharc.js | 33 - owl-bot-staging/v1p4beta1/.prettierrc.js | 22 - owl-bot-staging/v1p4beta1/README.md | 1 - .../v1p4beta1/linkinator.config.json | 16 - owl-bot-staging/v1p4beta1/package.json | 65 - .../google/cloud/vision/v1p4beta1/face.proto | 60 - .../cloud/vision/v1p4beta1/geometry.proto | 70 - .../vision/v1p4beta1/image_annotator.proto | 967 ------ .../vision/v1p4beta1/product_search.proto | 127 - .../v1p4beta1/product_search_service.proto | 1039 ------ .../vision/v1p4beta1/text_annotation.proto | 260 -- .../vision/v1p4beta1/web_detection.proto | 106 - ...ge_annotator.async_batch_annotate_files.js | 62 - ...e_annotator.async_batch_annotate_images.js | 67 - .../image_annotator.batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 77 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p4beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p4beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 71 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ------ owl-bot-staging/v1p4beta1/src/index.ts | 27 - .../src/v1p4beta1/gapic_metadata.json | 283 -- .../src/v1p4beta1/image_annotator_client.ts | 848 ----- .../image_annotator_client_config.json | 46 - .../v1p4beta1/image_annotator_proto_list.json | 9 - .../v1p4beta1/src/v1p4beta1/index.ts | 20 - .../src/v1p4beta1/product_search_client.ts | 2661 ---------------- .../product_search_client_config.json | 120 - .../v1p4beta1/product_search_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p4beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p4beta1.ts | 670 ---- .../test/gapic_product_search_v1p4beta1.ts | 2836 ----------------- owl-bot-staging/v1p4beta1/tsconfig.json | 19 - owl-bot-staging/v1p4beta1/webpack.config.js | 64 - .../cloud/vision/v1/image_annotator.proto | 3 +- .../vision/v1p1beta1/image_annotator.proto | 3 +- .../vision/v1p2beta1/image_annotator.proto | 3 +- .../vision/v1p3beta1/image_annotator.proto | 3 +- .../vision/v1p4beta1/image_annotator.proto | 3 +- 223 files changed, 10 insertions(+), 43506 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1p1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p1beta1/.gitignore delete mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p1beta1/README.md delete mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p1beta1/package.json delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json delete mode 100644 owl-bot-staging/v1p1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p2beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p2beta1/.gitignore delete mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p2beta1/README.md delete mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p2beta1/package.json delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json delete mode 100644 owl-bot-staging/v1p2beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts delete mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p3beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p3beta1/.gitignore delete mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p3beta1/README.md delete mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p3beta1/package.json delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json delete mode 100644 owl-bot-staging/v1p3beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p4beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p4beta1/.gitignore delete mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p4beta1/README.md delete mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p4beta1/package.json delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json delete mode 100644 owl-bot-staging/v1p4beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto deleted file mode 100644 index 7e0d24c2..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto deleted file mode 100644 index 6fed6112..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto +++ /dev/null @@ -1,1044 +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.vision.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search.proto"; -import "google/cloud/vision/v1/text_annotation.proto"; -import "google/cloud/vision/v1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1/images:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1/files:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/images:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/files:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateImages requests. It does - // not work for AsyncBatchAnnotateImages requests. - bytes content = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - - // Left cheek center. - LEFT_CHEEK_CENTER = 35; - - // Right cheek center. - RIGHT_CHEEK_CENTER = 36; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only one - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 3; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto deleted file mode 100644 index a2a98505..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto deleted file mode 100644 index 65680d90..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto +++ /dev/null @@ -1,1022 +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.vision.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/vision/v1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or - // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are - // still supported, but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1.Product.product_category], and the - // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a - // space (" "). You can update the `display_name` later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto deleted file mode 100644 index 9c07c322..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto +++ /dev/null @@ -1,258 +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.vision.v1; - -import "google/cloud/vision/v1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more -// detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto deleted file mode 100644 index 369a1350..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 7d7ed138..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 70be298e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 528c4d1f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 2f57a691..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js deleted file mode 100644 index 1826ada2..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js deleted file mode 100644 index 9e064a95..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { - // [START vision_v1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js deleted file mode 100644 index 5c580189..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js deleted file mode 100644 index 6175cef1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js deleted file mode 100644 index 8d58541b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js deleted file mode 100644 index 5c5b8125..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js deleted file mode 100644 index 18a64743..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js deleted file mode 100644 index 27e014db..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js deleted file mode 100644 index fa80ab00..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js deleted file mode 100644 index b25fb5e6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js deleted file mode 100644 index 859e0f5a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js deleted file mode 100644 index 66a071b0..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js deleted file mode 100644 index 8fa795f6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js deleted file mode 100644 index 3e9871fc..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js deleted file mode 100644 index f7175d39..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js deleted file mode 100644 index 0dae0b9b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js deleted file mode 100644 index ad66ef6b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js deleted file mode 100644 index d8fd49f9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js deleted file mode 100644 index 26bf5ed6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json deleted file mode 100644 index def101a1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1.OutputConfig" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 67a41d87..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /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. ** - -import * as v1 from './v1'; -const ImageAnnotatorClient = v1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1.ImageAnnotatorClient; -const ProductSearchClient = v1.ProductSearchClient; -type ProductSearchClient = v1.ProductSearchClient; -export {v1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 13fb1dac..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts deleted file mode 100644 index ea2296c7..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client.ts +++ /dev/null @@ -1,921 +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/v1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. - * 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/image_annotator.batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. - * 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/image_annotator.batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - 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.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - 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.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json deleted file mode 100644 index 08f87df9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts deleted file mode 100644 index 7e03c2b8..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client.ts +++ /dev/null @@ -1,2654 +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} 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/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.create_product_set.js - * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.get_product_set.js - * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.update_product_set.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product_set.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.create_product.js - * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.get_product.js - * region_tag:vision_v1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.update_product.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.create_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.get_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.add_product_to_product_set.js - * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products.js - * region_tag:vision_v1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js - * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products_in_product_set.js - * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json deleted file mode 100644 index b7db1b90..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client_config.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts deleted file mode 100644 index 64295d79..00000000 --- a/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts +++ /dev/null @@ -1,784 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts deleted file mode 100644 index e8ec2247..00000000 --- a/owl-bot-staging/v1/test/gapic_product_search_v1.ts +++ /dev/null @@ -1,2836 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1.ProductSearchClient({ - 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 productsearchModule.v1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'vision', - filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p1beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json deleted file mode 100644 index ac8fd32c..00000000 --- a/owl-bot-staging/v1p1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto deleted file mode 100644 index 6d46d9c3..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// 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 bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto deleted file mode 100644 index f66ad504..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ /dev/null @@ -1,618 +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.vision.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p1beta1/geometry.proto"; -import "google/cloud/vision/v1p1beta1/text_annotation.proto"; -import "google/cloud/vision/v1p1beta1/web_detection.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p1beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } -} - -// Users describe the type of Google Cloud Vision API tasks to perform over -// images by using *Feature*s. Each Feature indicates a type of image -// detection task to perform. Features encode the Cloud Vision API -// vertical to operate on and the number of top-scoring results to return. -message Feature { - // Type of image feature. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run OCR. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run computer vision models to compute image safe-search properties. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage image location). -message ImageSource { - // NOTE: For new code `image_uri` below is preferred. - // Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - string gcs_image_uri = 1; - - // Image URI which supports: - // 1) Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - // 2) Publicly accessible image HTTP/HTTPS URL. - // This is preferred over the legacy `gcs_image_uri` above. When both - // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location. If both `content` and `source` - // are provided for an image, `content` takes precedence and is - // used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // lat/long rectangle that specifies the location of the image. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto deleted file mode 100644 index f85cc44d..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -import "google/cloud/vision/v1p1beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width in pixels. - int32 width = 2; - - // Page height in pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto deleted file mode 100644 index c50e1ad6..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index eb0fe422..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json deleted file mode 100644 index dbece339..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p1beta1", - "version": "v1p1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts deleted file mode 100644 index 1137dce5..00000000 --- a/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; -const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -export {v1p1beta1, ImageAnnotatorClient}; -export default {v1p1beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json deleted file mode 100644 index 2dc79630..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts deleted file mode 100644 index 092acab0..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts +++ /dev/null @@ -1,373 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1p1beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p1beta1 - */ -export class ImageAnnotatorClient { - 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}; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p1beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. - * 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/v1p1beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json deleted file mode 100644 index 469fb95c..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p1beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json deleted file mode 100644 index 35609fc8..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts deleted file mode 100644 index a7fde53a..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts +++ /dev/null @@ -1,209 +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 imageannotatorModule from '../src'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1p1beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p1beta1/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: 'vision', - filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p2beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p2beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json deleted file mode 100644 index ac8fd32c..00000000 --- a/owl-bot-staging/v1p2beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto deleted file mode 100644 index e9fec20b..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto deleted file mode 100644 index 264462d4..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ /dev/null @@ -1,794 +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.vision.v1p2beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p2beta1/geometry.proto"; -import "google/cloud/vision/v1p2beta1/text_annotation.proto"; -import "google/cloud/vision/v1p2beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p2beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run async image detection and annotation for a list of generic files (e.g. - // PDF) which may contain multiple pages and multiple images per page. - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p2beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file on GCS. - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a GCS - // object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto deleted file mode 100644 index af568194..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -import "google/cloud/vision/v1p2beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto deleted file mode 100644 index 2decb859..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 92074c3a..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 793ec83e..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json deleted file mode 100644 index c843af75..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p2beta1", - "version": "v1p2beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts deleted file mode 100644 index 0e8fea74..00000000 --- a/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; -const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -export {v1p2beta1, ImageAnnotatorClient}; -export default {v1p2beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json deleted file mode 100644 index 116ff853..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts deleted file mode 100644 index 399a91e4..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts +++ /dev/null @@ -1,492 +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/v1p2beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p2beta1 - */ -export class ImageAnnotatorClient { - 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; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p2beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. - * 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/v1p2beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run async image detection and annotation for a list of generic files (e.g. - * PDF) which may contain multiple pages and multiple images per page. - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json deleted file mode 100644 index 367627eb..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p2beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json deleted file mode 100644 index 2b5904f9..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts deleted file mode 100644 index 770639d0..00000000 --- a/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts +++ /dev/null @@ -1,337 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p2beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p2beta1/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: 'vision', - filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p3beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p3beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1p3beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto deleted file mode 100644 index c2c524fb..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto deleted file mode 100644 index ebab14a6..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ /dev/null @@ -1,833 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search.proto"; -import "google/cloud/vision/v1p3beta1/text_annotation.proto"; -import "google/cloud/vision/v1p3beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p3beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = - 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto deleted file mode 100644 index 86ea1a06..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1p3beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto deleted file mode 100644 index daf1d0dd..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto +++ /dev/null @@ -1,971 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. All Products and ReferenceImages in the - // ProductSet will be deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only display_name, description and labels can be updated right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - // - // Possible errors: - // - // * Returns NOT_FOUND if the product does not exist. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the reference image does not exist. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND If the Product is not found under the ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories - // "homegoods", "apparel", and "toys" are still supported, but these should - // not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 100 product_labels. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this field is 0. - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 6 columns. - // 1. image_uri - // 2, image_id - // 3. product_set_id - // 4. product_id - // 5, product_category - // 6, product_display_name - // 7, labels - // 8. bounding_poly - // - // Columns 1, 3, 4, and 5 are required, other columns are optional. A new - // ProductSet/Product with the same id will be created on the fly - // if the ProductSet/Product specified by product_set_id/product_id does not - // exist. - // - // The image_id field is optional but has to be unique if provided. If it is - // empty, we will automatically assign an unique id to the image. - // - // The product_display_name field is optional. If it is empty, a space (" ") - // is used as the place holder for the product display_name, which can - // be updated later through the realtime API. - // - // If the Product with product_id already exists, the fields - // product_display_name, product_category and labels are ignored. - // - // If a Product doesn't exist and needs to be created on the fly, the - // product_display_name field refers to - // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], - // the product_category field refers to - // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], - // and the labels field refers to [Product.labels][]. - // - // Labels (optional) should be a line containing a list of comma-separated - // key-value pairs, with the format - // "key_1=value_1,key_2=value_2,...,key_n=value_n". - // - // The bounding_poly (optional) field is used to identify one region of - // interest from the image in the same manner as CreateReferenceImage. If no - // bounding_poly is specified, the system will try to detect regions of - // interest automatically. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 20MP). - // - // Also note that at most one bounding_poly is allowed per line. If the image - // contains multiple regions of interest, the csv should contain one line per - // region of interest. - // - // The bounding_poly column should contain an even number of comma-separated - // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative - // integers should be used for absolute bounding polygons, and float values - // in [0, 1] should be used for normalized bounding polygons. - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto deleted file mode 100644 index 633e404e..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -import "google/cloud/vision/v1p3beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto deleted file mode 100644 index 205dfe65..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 900c1b0b..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 1b58eca1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Individual image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index 96b4c8ba..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js deleted file mode 100644 index ed6ac1b8..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js deleted file mode 100644 index 90879035..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js deleted file mode 100644 index 48848360..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js deleted file mode 100644 index a5872042..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js deleted file mode 100644 index 7d971bc3..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js deleted file mode 100644 index c97f2727..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js deleted file mode 100644 index c62e8ea6..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js deleted file mode 100644 index 4def76dc..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js deleted file mode 100644 index 93ee9d82..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js deleted file mode 100644 index 23698c04..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js deleted file mode 100644 index 52033c07..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js deleted file mode 100644 index 454672d1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 65bc35e2..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js deleted file mode 100644 index 9deb4e05..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index 45dcddaf..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js deleted file mode 100644 index 8d98838c..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js deleted file mode 100644 index cfecdb70..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json deleted file mode 100644 index 90042759..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p3beta1", - "version": "v1p3beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts deleted file mode 100644 index 9e656a03..00000000 --- a/owl-bot-staging/v1p3beta1/src/index.ts +++ /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. ** - -import * as v1p3beta1 from './v1p3beta1'; -const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p3beta1.ProductSearchClient; -type ProductSearchClient = v1p3beta1.ProductSearchClient; -export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json deleted file mode 100644 index 52ae14a4..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p3beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts deleted file mode 100644 index 2114aa92..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts +++ /dev/null @@ -1,671 +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/v1p3beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p3beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. - * 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/v1p3beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json deleted file mode 100644 index 75a2b706..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts deleted file mode 100644 index 2dacf41c..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts +++ /dev/null @@ -1,2538 +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} 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/v1p3beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p3beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.create_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.get_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.update_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. All Products and ReferenceImages in the - * ProductSet will be deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.create_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.get_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only display_name, description and labels can be updated right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.update_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * Possible errors: - * - * * Returns NOT_FOUND if the product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.create_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the reference image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.get_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND If the Product is not found under the ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json deleted file mode 100644 index ddc1e9ad..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts deleted file mode 100644 index 66892759..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts +++ /dev/null @@ -1,486 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p3beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts deleted file mode 100644 index b8a9d88b..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts +++ /dev/null @@ -1,2692 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p3beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p3beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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 productsearchModule.v1p3beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p3beta1/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: 'vision', - filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p4beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p4beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json deleted file mode 100644 index 5ccecd9d..00000000 --- a/owl-bot-staging/v1p4beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.3.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.56", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.0", - "linkinator": "^4.0.2", - "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.2", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto deleted file mode 100644 index d2ab72f0..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto +++ /dev/null @@ -1,60 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "CelebrityProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a celebrity recognition request. -message FaceRecognitionParams { - // The resource names for one or more - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity - // set is preloaded and can be specified as "builtin/default". If this is - // specified, the algorithm will try to match the faces detected in the input - // image to the Celebrities in the CelebritySets. - repeated string celebrity_set = 1; -} - -// A Celebrity is a group of Faces with an identity. -message Celebrity { - // The resource name of the preloaded Celebrity. Has the format - // `builtin/{mid}`. - string name = 1; - - // The Celebrity's display name. - string display_name = 2; - - // The Celebrity's description. - string description = 3; -} - -// Information about a face's identity. -message FaceRecognitionResult { - // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was - // matched to. - Celebrity celebrity = 1; - - // Recognition confidence. Range [0, 1]. - float confidence = 2; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto deleted file mode 100644 index 877fd897..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto +++ /dev/null @@ -1,70 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto deleted file mode 100644 index cc783697..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ /dev/null @@ -1,967 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p4beta1/face.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search.proto"; -import "google/cloud/vision/v1p4beta1/text_annotation.proto"; -import "google/cloud/vision/v1p4beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) - returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/files:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/images:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; - - // Additional recognition information. Only computed if - // image_context.face_recognition_params is provided, **and** a match is found - // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is - // sorted in order of decreasing confidence values. - repeated FaceRecognitionResult recognition_result = 16; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for face recognition. - FaceRecognitionParams face_recognition_params = 10; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only - // one AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto deleted file mode 100644 index ebb428ac..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto +++ /dev/null @@ -1,127 +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.vision.v1p4beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a - // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for - // similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto deleted file mode 100644 index df7bc7a3..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto +++ /dev/null @@ -1,1039 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of -// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of -// [Product][google.cloud.vision.v1p4beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of -// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, -// named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) - returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = - "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. - // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The - // legacy categories "homegoods", "apparel", and "toys" are still supported, - // but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference - // image. If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference - // image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this - // ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], - // and the `labels` column refers to - // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] - // field for the product to a space (" "). You can update the `display_name` - // later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto deleted file mode 100644 index 233c4c68..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto +++ /dev/null @@ -1,260 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto deleted file mode 100644 index 7d716570..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto +++ /dev/null @@ -1,106 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 199be36a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 8cb5197f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 2fe101f3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index f6aaa34e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index c6ef04f0..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js deleted file mode 100644 index 60ec6540..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js deleted file mode 100644 index ea4c348b..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js deleted file mode 100644 index bb6709c3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, referenceImage) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference - * image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js deleted file mode 100644 index 63f362dc..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js deleted file mode 100644 index 72ac7fec..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js deleted file mode 100644 index 92f9f39c..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js deleted file mode 100644 index 80db0f5a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js deleted file mode 100644 index acba73c5..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js deleted file mode 100644 index 5dc13d64..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js deleted file mode 100644 index 3a422698..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js deleted file mode 100644 index 81e409fa..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js deleted file mode 100644 index 8b67070e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 869b118f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js deleted file mode 100644 index 637c1f8a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js deleted file mode 100644 index 5dd66449..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index af9e9c14..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,71 +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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this - * ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js deleted file mode 100644 index 3c8d60bb..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js deleted file mode 100644 index 6ceb8322..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json deleted file mode 100644 index 65c6af72..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json +++ /dev/null @@ -1,1027 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p4beta1", - "version": "v1p4beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1p4beta1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts deleted file mode 100644 index 464f947a..00000000 --- a/owl-bot-staging/v1p4beta1/src/index.ts +++ /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. ** - -import * as v1p4beta1 from './v1p4beta1'; -const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p4beta1.ProductSearchClient; -type ProductSearchClient = v1p4beta1.ProductSearchClient; -export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json deleted file mode 100644 index 8338e641..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p4beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts deleted file mode 100644 index cb620c40..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts +++ /dev/null @@ -1,848 +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/v1p4beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p4beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json deleted file mode 100644 index e068ba98..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts deleted file mode 100644 index 6e9bcc4b..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts +++ /dev/null @@ -1,2661 +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} 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/v1p4beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of - * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, - * named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p4beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.create_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.get_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.update_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.create_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.get_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.update_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference - * image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.create_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.get_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this - * ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name || '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json deleted file mode 100644 index 518529b7..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts deleted file mode 100644 index 5fb3c9d9..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts +++ /dev/null @@ -1,670 +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 imageannotatorModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p4beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse()); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse()); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts deleted file mode 100644 index 5a2d84cc..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts +++ /dev/null @@ -1,2836 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p4beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p4beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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 productsearchModule.v1p4beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - assert((client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - assert((client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = "product_set.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - assert((client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest()); - request.productSet = {}; - request.productSet.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - assert((client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - assert((client.innerApiCalls.createProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateProductRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - assert((client.innerApiCalls.getProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = "product.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - assert((client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest()); - request.product = {}; - request.product.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - assert((client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - assert((client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert((client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - assert((client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - assert((client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - assert((client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - assert((client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert.strictEqual( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - assert((client.innerApiCalls.listProducts as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert.strictEqual( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - assert((client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - assert((client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p4beta1/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: 'vision', - filename: './vision.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/protos/google/cloud/vision/v1/image_annotator.proto b/protos/google/cloud/vision/v1/image_annotator.proto index 10464b0e..6fed6112 100644 --- a/protos/google/cloud/vision/v1/image_annotator.proto +++ b/protos/google/cloud/vision/v1/image_annotator.proto @@ -223,7 +223,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/protos/google/cloud/vision/v1p1beta1/image_annotator.proto index 729a0fa0..f66ad504 100644 --- a/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -103,7 +103,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/protos/google/cloud/vision/v1p2beta1/image_annotator.proto index 5fc3163c..264462d4 100644 --- a/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -126,7 +126,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/protos/google/cloud/vision/v1p3beta1/image_annotator.proto index ca0b4e86..ebab14a6 100644 --- a/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -134,7 +134,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/protos/google/cloud/vision/v1p4beta1/image_annotator.proto index 0fed9eea..cc783697 100644 --- a/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -175,7 +175,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } From 8ac0e911de15a5e04bc4066dcfd2e7ad3e35b026 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 14 Sep 2022 20:16:48 +0000 Subject: [PATCH 5/9] chore: use gapic-generator-typescript v2.17.0 PiperOrigin-RevId: 474338479 Source-Link: https://github.com/googleapis/googleapis/commit/d5d35e0353b59719e8917103b1bc7df2782bf6ba Source-Link: https://github.com/googleapis/googleapis-gen/commit/efcd3f93962a103f68f003e2a1eecde6fa216a27 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWZjZDNmOTM5NjJhMTAzZjY4ZjAwM2UyYTFlZWNkZTZmYTIxNmEyNyJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 65 + .../google/cloud/vision/v1/geometry.proto | 68 + .../cloud/vision/v1/image_annotator.proto | 1044 ++++++ .../cloud/vision/v1/product_search.proto | 124 + .../vision/v1/product_search_service.proto | 1022 ++++++ .../cloud/vision/v1/text_annotation.proto | 258 ++ .../cloud/vision/v1/web_detection.proto | 104 + ...ge_annotator.async_batch_annotate_files.js | 73 + ...e_annotator.async_batch_annotate_images.js | 78 + .../image_annotator.batch_annotate_files.js | 73 + .../image_annotator.batch_annotate_images.js | 72 + ...oduct_search.add_product_to_product_set.js | 70 + .../v1/product_search.create_product.js | 75 + .../v1/product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../v1/product_search.delete_product.js | 63 + .../v1/product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1/product_search.get_product.js | 63 + .../v1/product_search.get_product_set.js | 63 + .../v1/product_search.get_reference_image.js | 63 + .../v1/product_search.import_product_sets.js | 68 + .../v1/product_search.list_product_sets.js | 72 + .../v1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../v1/product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 70 + .../v1/product_search.update_product.js | 70 + .../v1/product_search.update_product_set.js | 68 + ...ippet_metadata.google.cloud.vision.v1.json | 1043 ++++++ owl-bot-staging/v1/src/index.ts | 27 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 ++ .../v1/src/v1/image_annotator_client.ts | 921 +++++ .../src/v1/image_annotator_client_config.json | 46 + .../v1/src/v1/image_annotator_proto_list.json | 8 + owl-bot-staging/v1/src/v1/index.ts | 20 + .../v1/src/v1/product_search_client.ts | 2654 ++++++++++++++ .../src/v1/product_search_client_config.json | 121 + .../v1/src/v1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_image_annotator_v1.ts | 839 +++++ .../v1/test/gapic_product_search_v1.ts | 3100 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1p1beta1/.eslintignore | 7 + owl-bot-staging/v1p1beta1/.eslintrc.json | 3 + owl-bot-staging/v1p1beta1/.gitignore | 14 + owl-bot-staging/v1p1beta1/.jsdoc.js | 55 + owl-bot-staging/v1p1beta1/.mocharc.js | 33 + owl-bot-staging/v1p1beta1/.prettierrc.js | 22 + owl-bot-staging/v1p1beta1/README.md | 1 + .../v1p1beta1/linkinator.config.json | 16 + owl-bot-staging/v1p1beta1/package.json | 64 + .../cloud/vision/v1p1beta1/geometry.proto | 53 + .../vision/v1p1beta1/image_annotator.proto | 618 ++++ .../vision/v1p1beta1/text_annotation.proto | 251 ++ .../vision/v1p1beta1/web_detection.proto | 103 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p1beta1.json | 55 + owl-bot-staging/v1p1beta1/src/index.ts | 25 + .../src/v1p1beta1/gapic_metadata.json | 33 + .../src/v1p1beta1/image_annotator_client.ts | 373 ++ .../image_annotator_client_config.json | 31 + .../v1p1beta1/image_annotator_proto_list.json | 6 + .../v1p1beta1/src/v1p1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p1beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p1beta1.ts | 225 ++ owl-bot-staging/v1p1beta1/tsconfig.json | 19 + owl-bot-staging/v1p1beta1/webpack.config.js | 64 + owl-bot-staging/v1p2beta1/.eslintignore | 7 + owl-bot-staging/v1p2beta1/.eslintrc.json | 3 + owl-bot-staging/v1p2beta1/.gitignore | 14 + owl-bot-staging/v1p2beta1/.jsdoc.js | 55 + owl-bot-staging/v1p2beta1/.mocharc.js | 33 + owl-bot-staging/v1p2beta1/.prettierrc.js | 22 + owl-bot-staging/v1p2beta1/README.md | 1 + .../v1p2beta1/linkinator.config.json | 16 + owl-bot-staging/v1p2beta1/package.json | 64 + .../cloud/vision/v1p2beta1/geometry.proto | 67 + .../vision/v1p2beta1/image_annotator.proto | 794 +++++ .../vision/v1p2beta1/text_annotation.proto | 258 ++ .../vision/v1p2beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p2beta1.json | 95 + owl-bot-staging/v1p2beta1/src/index.ts | 25 + .../src/v1p2beta1/gapic_metadata.json | 43 + .../src/v1p2beta1/image_annotator_client.ts | 492 +++ .../image_annotator_client_config.json | 36 + .../v1p2beta1/image_annotator_proto_list.json | 6 + .../v1p2beta1/src/v1p2beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p2beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p2beta1.ts | 355 ++ owl-bot-staging/v1p2beta1/tsconfig.json | 19 + owl-bot-staging/v1p2beta1/webpack.config.js | 64 + owl-bot-staging/v1p3beta1/.eslintignore | 7 + owl-bot-staging/v1p3beta1/.eslintrc.json | 3 + owl-bot-staging/v1p3beta1/.gitignore | 14 + owl-bot-staging/v1p3beta1/.jsdoc.js | 55 + owl-bot-staging/v1p3beta1/.mocharc.js | 33 + owl-bot-staging/v1p3beta1/.prettierrc.js | 22 + owl-bot-staging/v1p3beta1/README.md | 1 + .../v1p3beta1/linkinator.config.json | 16 + owl-bot-staging/v1p3beta1/package.json | 65 + .../cloud/vision/v1p3beta1/geometry.proto | 68 + .../vision/v1p3beta1/image_annotator.proto | 833 +++++ .../vision/v1p3beta1/product_search.proto | 124 + .../v1p3beta1/product_search_service.proto | 971 ++++++ .../vision/v1p3beta1/text_annotation.proto | 258 ++ .../vision/v1p3beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p3beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p3beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + ..._search.remove_product_from_product_set.js | 70 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p3beta1.json | 891 +++++ owl-bot-staging/v1p3beta1/src/index.ts | 27 + .../src/v1p3beta1/gapic_metadata.json | 253 ++ .../src/v1p3beta1/image_annotator_client.ts | 671 ++++ .../image_annotator_client_config.json | 36 + .../v1p3beta1/image_annotator_proto_list.json | 8 + .../v1p3beta1/src/v1p3beta1/index.ts | 20 + .../src/v1p3beta1/product_search_client.ts | 2538 ++++++++++++++ .../product_search_client_config.json | 116 + .../v1p3beta1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p3beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p3beta1.ts | 504 +++ .../test/gapic_product_search_v1p3beta1.ts | 2946 ++++++++++++++++ owl-bot-staging/v1p3beta1/tsconfig.json | 19 + owl-bot-staging/v1p3beta1/webpack.config.js | 64 + owl-bot-staging/v1p4beta1/.eslintignore | 7 + owl-bot-staging/v1p4beta1/.eslintrc.json | 3 + owl-bot-staging/v1p4beta1/.gitignore | 14 + owl-bot-staging/v1p4beta1/.jsdoc.js | 55 + owl-bot-staging/v1p4beta1/.mocharc.js | 33 + owl-bot-staging/v1p4beta1/.prettierrc.js | 22 + owl-bot-staging/v1p4beta1/README.md | 1 + .../v1p4beta1/linkinator.config.json | 16 + owl-bot-staging/v1p4beta1/package.json | 65 + .../google/cloud/vision/v1p4beta1/face.proto | 60 + .../cloud/vision/v1p4beta1/geometry.proto | 70 + .../vision/v1p4beta1/image_annotator.proto | 967 +++++ .../vision/v1p4beta1/product_search.proto | 127 + .../v1p4beta1/product_search_service.proto | 1039 ++++++ .../vision/v1p4beta1/text_annotation.proto | 260 ++ .../vision/v1p4beta1/web_detection.proto | 106 + ...ge_annotator.async_batch_annotate_files.js | 62 + ...e_annotator.async_batch_annotate_images.js | 67 + .../image_annotator.batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 77 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p4beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p4beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 71 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ++++++ owl-bot-staging/v1p4beta1/src/index.ts | 27 + .../src/v1p4beta1/gapic_metadata.json | 283 ++ .../src/v1p4beta1/image_annotator_client.ts | 848 +++++ .../image_annotator_client_config.json | 46 + .../v1p4beta1/image_annotator_proto_list.json | 9 + .../v1p4beta1/src/v1p4beta1/index.ts | 20 + .../src/v1p4beta1/product_search_client.ts | 2661 ++++++++++++++ .../product_search_client_config.json | 120 + .../v1p4beta1/product_search_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p4beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p4beta1.ts | 693 ++++ .../test/gapic_product_search_v1p4beta1.ts | 3100 +++++++++++++++++ owl-bot-staging/v1p4beta1/tsconfig.json | 19 + owl-bot-staging/v1p4beta1/webpack.config.js | 64 + 218 files changed, 44413 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1p1beta1/.eslintignore create mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p1beta1/.gitignore create mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p1beta1/README.md create mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p1beta1/package.json create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json create mode 100644 owl-bot-staging/v1p1beta1/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p2beta1/.eslintignore create mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p2beta1/.gitignore create mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p2beta1/README.md create mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p2beta1/package.json create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json create mode 100644 owl-bot-staging/v1p2beta1/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts create mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p3beta1/.eslintignore create mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p3beta1/.gitignore create mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p3beta1/README.md create mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p3beta1/package.json create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json create mode 100644 owl-bot-staging/v1p3beta1/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p4beta1/.eslintignore create mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p4beta1/.gitignore create mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p4beta1/README.md create mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p4beta1/package.json create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json create mode 100644 owl-bot-staging/v1p4beta1/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto new file mode 100644 index 00000000..7e0d24c2 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto new file mode 100644 index 00000000..6fed6112 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto @@ -0,0 +1,1044 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search.proto"; +import "google/cloud/vision/v1/text_annotation.proto"; +import "google/cloud/vision/v1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1/images:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1/files:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/images:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/files:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateImages requests. It does + // not work for AsyncBatchAnnotateImages requests. + bytes content = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + + // Left cheek center. + LEFT_CHEEK_CENTER = 35; + + // Right cheek center. + RIGHT_CHEEK_CENTER = 36; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 3; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto new file mode 100644 index 00000000..a2a98505 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto new file mode 100644 index 00000000..65680d90 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto @@ -0,0 +1,1022 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.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/vision/v1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or + // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are + // still supported, but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1.Product.product_category], and the + // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a + // space (" "). You can update the `display_name` later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto new file mode 100644 index 00000000..9c07c322 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/cloud/vision/v1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more +// detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto new file mode 100644 index 00000000..369a1350 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..7d7ed138 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..70be298e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..528c4d1f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..2f57a691 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..1826ada2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js new file mode 100644 index 00000000..9e064a95 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { + // [START vision_v1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js new file mode 100644 index 00000000..5c580189 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js new file mode 100644 index 00000000..6175cef1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js new file mode 100644 index 00000000..8d58541b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js new file mode 100644 index 00000000..5c5b8125 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js new file mode 100644 index 00000000..18a64743 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js new file mode 100644 index 00000000..27e014db --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js new file mode 100644 index 00000000..fa80ab00 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js new file mode 100644 index 00000000..b25fb5e6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js new file mode 100644 index 00000000..859e0f5a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js new file mode 100644 index 00000000..66a071b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js new file mode 100644 index 00000000..8fa795f6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..3e9871fc --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js new file mode 100644 index 00000000..f7175d39 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js new file mode 100644 index 00000000..0dae0b9b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..ad66ef6b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js new file mode 100644 index 00000000..d8fd49f9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js new file mode 100644 index 00000000..26bf5ed6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json new file mode 100644 index 00000000..def101a1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json @@ -0,0 +1,1043 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1.OutputConfig" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..67a41d87 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ImageAnnotatorClient = v1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1.ImageAnnotatorClient; +const ProductSearchClient = v1.ProductSearchClient; +type ProductSearchClient = v1.ProductSearchClient; +export {v1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..13fb1dac --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts new file mode 100644 index 00000000..3fef9c7b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client.ts @@ -0,0 +1,921 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. + * 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/image_annotator.batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * 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/image_annotator.batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + 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.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + 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.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json new file mode 100644 index 00000000..08f87df9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts new file mode 100644 index 00000000..dc96f48b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client.ts @@ -0,0 +1,2654 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.create_product_set.js + * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.get_product_set.js + * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.update_product_set.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product_set.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.create_product.js + * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.get_product.js + * region_tag:vision_v1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.update_product.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.create_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.get_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.add_product_to_product_set.js + * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products.js + * region_tag:vision_v1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js + * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products_in_product_set.js + * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json new file mode 100644 index 00000000..b7db1b90 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client_config.json @@ -0,0 +1,121 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts new file mode 100644 index 00000000..e1102cdb --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts @@ -0,0 +1,839 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + 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.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts new file mode 100644 index 00000000..b8aa68c4 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_product_search_v1.ts @@ -0,0 +1,3100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1.ProductSearchClient({ + 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 productsearchModule.v1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|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.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'vision', + filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json new file mode 100644 index 00000000..a08f8678 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto new file mode 100644 index 00000000..6d46d9c3 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// 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 bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto new file mode 100644 index 00000000..f66ad504 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -0,0 +1,618 @@ +// 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.vision.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p1beta1/geometry.proto"; +import "google/cloud/vision/v1p1beta1/text_annotation.proto"; +import "google/cloud/vision/v1p1beta1/web_detection.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p1beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } +} + +// Users describe the type of Google Cloud Vision API tasks to perform over +// images by using *Feature*s. Each Feature indicates a type of image +// detection task to perform. Features encode the Cloud Vision API +// vertical to operate on and the number of top-scoring results to return. +message Feature { + // Type of image feature. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run OCR. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run computer vision models to compute image safe-search properties. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage image location). +message ImageSource { + // NOTE: For new code `image_uri` below is preferred. + // Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + string gcs_image_uri = 1; + + // Image URI which supports: + // 1) Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + // 2) Publicly accessible image HTTP/HTTPS URL. + // This is preferred over the legacy `gcs_image_uri` above. When both + // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location. If both `content` and `source` + // are provided for an image, `content` takes precedence and is + // used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // lat/long rectangle that specifies the location of the image. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto new file mode 100644 index 00000000..f85cc44d --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto @@ -0,0 +1,251 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +import "google/cloud/vision/v1p1beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width in pixels. + int32 width = 2; + + // Page height in pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto new file mode 100644 index 00000000..c50e1ad6 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..eb0fe422 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json new file mode 100644 index 00000000..dbece339 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p1beta1", + "version": "v1p1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts new file mode 100644 index 00000000..1137dce5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; +const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +export {v1p1beta1, ImageAnnotatorClient}; +export default {v1p1beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json new file mode 100644 index 00000000..2dc79630 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts new file mode 100644 index 00000000..092acab0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p1beta1 + */ +export class ImageAnnotatorClient { + 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}; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p1beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. + * 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/v1p1beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json new file mode 100644 index 00000000..469fb95c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.vision.v1p1beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..35609fc8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts new file mode 100644 index 00000000..cbaef061 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts @@ -0,0 +1,225 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1p1beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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: 'vision', + filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json new file mode 100644 index 00000000..a08f8678 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto new file mode 100644 index 00000000..e9fec20b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto @@ -0,0 +1,67 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto new file mode 100644 index 00000000..264462d4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -0,0 +1,794 @@ +// 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.vision.v1p2beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p2beta1/geometry.proto"; +import "google/cloud/vision/v1p2beta1/text_annotation.proto"; +import "google/cloud/vision/v1p2beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p2beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run async image detection and annotation for a list of generic files (e.g. + // PDF) which may contain multiple pages and multiple images per page. + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p2beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file on GCS. + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a GCS + // object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto new file mode 100644 index 00000000..af568194 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +import "google/cloud/vision/v1p2beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto new file mode 100644 index 00000000..2decb859 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..92074c3a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..793ec83e --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json new file mode 100644 index 00000000..c843af75 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json @@ -0,0 +1,95 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p2beta1", + "version": "v1p2beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts new file mode 100644 index 00000000..0e8fea74 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; +const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +export {v1p2beta1, ImageAnnotatorClient}; +export default {v1p2beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json new file mode 100644 index 00000000..116ff853 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts new file mode 100644 index 00000000..399a91e4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts @@ -0,0 +1,492 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p2beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p2beta1 + */ +export class ImageAnnotatorClient { + 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; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p2beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. + * 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/v1p2beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run async image detection and annotation for a list of generic files (e.g. + * PDF) which may contain multiple pages and multiple images per page. + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json new file mode 100644 index 00000000..367627eb --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p2beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..2b5904f9 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts new file mode 100644 index 00000000..5c8ad8dc --- /dev/null +++ b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts @@ -0,0 +1,355 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p2beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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: 'vision', + filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p3beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto new file mode 100644 index 00000000..c2c524fb --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto new file mode 100644 index 00000000..ebab14a6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -0,0 +1,833 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search.proto"; +import "google/cloud/vision/v1p3beta1/text_annotation.proto"; +import "google/cloud/vision/v1p3beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p3beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = + 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto new file mode 100644 index 00000000..86ea1a06 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto new file mode 100644 index 00000000..daf1d0dd --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto @@ -0,0 +1,971 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. All Products and ReferenceImages in the + // ProductSet will be deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only display_name, description and labels can be updated right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + // + // Possible errors: + // + // * Returns NOT_FOUND if the product does not exist. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the reference image does not exist. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND If the Product is not found under the ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories + // "homegoods", "apparel", and "toys" are still supported, but these should + // not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 100 product_labels. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this field is 0. + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 6 columns. + // 1. image_uri + // 2, image_id + // 3. product_set_id + // 4. product_id + // 5, product_category + // 6, product_display_name + // 7, labels + // 8. bounding_poly + // + // Columns 1, 3, 4, and 5 are required, other columns are optional. A new + // ProductSet/Product with the same id will be created on the fly + // if the ProductSet/Product specified by product_set_id/product_id does not + // exist. + // + // The image_id field is optional but has to be unique if provided. If it is + // empty, we will automatically assign an unique id to the image. + // + // The product_display_name field is optional. If it is empty, a space (" ") + // is used as the place holder for the product display_name, which can + // be updated later through the realtime API. + // + // If the Product with product_id already exists, the fields + // product_display_name, product_category and labels are ignored. + // + // If a Product doesn't exist and needs to be created on the fly, the + // product_display_name field refers to + // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], + // the product_category field refers to + // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], + // and the labels field refers to [Product.labels][]. + // + // Labels (optional) should be a line containing a list of comma-separated + // key-value pairs, with the format + // "key_1=value_1,key_2=value_2,...,key_n=value_n". + // + // The bounding_poly (optional) field is used to identify one region of + // interest from the image in the same manner as CreateReferenceImage. If no + // bounding_poly is specified, the system will try to detect regions of + // interest automatically. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 20MP). + // + // Also note that at most one bounding_poly is allowed per line. If the image + // contains multiple regions of interest, the csv should contain one line per + // region of interest. + // + // The bounding_poly column should contain an even number of comma-separated + // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative + // integers should be used for absolute bounding polygons, and float values + // in [0, 1] should be used for normalized bounding polygons. + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto new file mode 100644 index 00000000..633e404e --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/cloud/vision/v1p3beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto new file mode 100644 index 00000000..205dfe65 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..900c1b0b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..1b58eca1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Individual image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..96b4c8ba --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js new file mode 100644 index 00000000..ed6ac1b8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js new file mode 100644 index 00000000..90879035 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..48848360 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js new file mode 100644 index 00000000..a5872042 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..7d971bc3 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..c97f2727 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js new file mode 100644 index 00000000..c62e8ea6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js new file mode 100644 index 00000000..4def76dc --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..93ee9d82 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..23698c04 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..52033c07 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js new file mode 100644 index 00000000..454672d1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..65bc35e2 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..9deb4e05 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..45dcddaf --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js new file mode 100644 index 00000000..8d98838c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js new file mode 100644 index 00000000..cfecdb70 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json new file mode 100644 index 00000000..90042759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json @@ -0,0 +1,891 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p3beta1", + "version": "v1p3beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts new file mode 100644 index 00000000..9e656a03 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p3beta1 from './v1p3beta1'; +const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p3beta1.ProductSearchClient; +type ProductSearchClient = v1p3beta1.ProductSearchClient; +export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json new file mode 100644 index 00000000..52ae14a4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json @@ -0,0 +1,253 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p3beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts new file mode 100644 index 00000000..2114aa92 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts @@ -0,0 +1,671 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p3beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p3beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. + * 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/v1p3beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json new file mode 100644 index 00000000..75a2b706 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts new file mode 100644 index 00000000..facd3967 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts @@ -0,0 +1,2538 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p3beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p3beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.create_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.get_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.update_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. All Products and ReferenceImages in the + * ProductSet will be deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.create_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.get_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only display_name, description and labels can be updated right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.update_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * Possible errors: + * + * * Returns NOT_FOUND if the product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.create_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the reference image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.get_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND If the Product is not found under the ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json new file mode 100644 index 00000000..ddc1e9ad --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json @@ -0,0 +1,116 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts new file mode 100644 index 00000000..7e683838 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts @@ -0,0 +1,504 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p3beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts new file mode 100644 index 00000000..5fd1b0bd --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts @@ -0,0 +1,2946 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p3beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p3beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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 productsearchModule.v1p3beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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: 'vision', + filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto new file mode 100644 index 00000000..d2ab72f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto @@ -0,0 +1,60 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "CelebrityProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a celebrity recognition request. +message FaceRecognitionParams { + // The resource names for one or more + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity + // set is preloaded and can be specified as "builtin/default". If this is + // specified, the algorithm will try to match the faces detected in the input + // image to the Celebrities in the CelebritySets. + repeated string celebrity_set = 1; +} + +// A Celebrity is a group of Faces with an identity. +message Celebrity { + // The resource name of the preloaded Celebrity. Has the format + // `builtin/{mid}`. + string name = 1; + + // The Celebrity's display name. + string display_name = 2; + + // The Celebrity's description. + string description = 3; +} + +// Information about a face's identity. +message FaceRecognitionResult { + // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was + // matched to. + Celebrity celebrity = 1; + + // Recognition confidence. Range [0, 1]. + float confidence = 2; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto new file mode 100644 index 00000000..877fd897 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto @@ -0,0 +1,70 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto new file mode 100644 index 00000000..cc783697 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -0,0 +1,967 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p4beta1/face.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search.proto"; +import "google/cloud/vision/v1p4beta1/text_annotation.proto"; +import "google/cloud/vision/v1p4beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) + returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/files:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/images:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; + + // Additional recognition information. Only computed if + // image_context.face_recognition_params is provided, **and** a match is found + // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is + // sorted in order of decreasing confidence values. + repeated FaceRecognitionResult recognition_result = 16; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for face recognition. + FaceRecognitionParams face_recognition_params = 10; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only + // one AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto new file mode 100644 index 00000000..ebb428ac --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto @@ -0,0 +1,127 @@ +// 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.vision.v1p4beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a + // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for + // similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto new file mode 100644 index 00000000..df7bc7a3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto @@ -0,0 +1,1039 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of +// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of +// [Product][google.cloud.vision.v1p4beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of +// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, +// named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) + returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = + "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. + // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The + // legacy categories "homegoods", "apparel", and "toys" are still supported, + // but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference + // image. If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference + // image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this + // ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], + // and the `labels` column refers to + // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] + // field for the product to a space (" "). You can update the `display_name` + // later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto new file mode 100644 index 00000000..233c4c68 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto @@ -0,0 +1,260 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto new file mode 100644 index 00000000..7d716570 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto @@ -0,0 +1,106 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..199be36a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..8cb5197f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..2fe101f3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..f6aaa34e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..c6ef04f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js new file mode 100644 index 00000000..60ec6540 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js new file mode 100644 index 00000000..ea4c348b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..bb6709c3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference + * image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js new file mode 100644 index 00000000..63f362dc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..72ac7fec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..92f9f39c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js new file mode 100644 index 00000000..80db0f5a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js new file mode 100644 index 00000000..acba73c5 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..5dc13d64 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..3a422698 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..81e409fa --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js new file mode 100644 index 00000000..8b67070e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..869b118f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..637c1f8a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js new file mode 100644 index 00000000..5dd66449 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..af9e9c14 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this + * ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js new file mode 100644 index 00000000..3c8d60bb --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js new file mode 100644 index 00000000..6ceb8322 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json new file mode 100644 index 00000000..65c6af72 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json @@ -0,0 +1,1027 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p4beta1", + "version": "v1p4beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1p4beta1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts new file mode 100644 index 00000000..464f947a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p4beta1 from './v1p4beta1'; +const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p4beta1.ProductSearchClient; +type ProductSearchClient = v1p4beta1.ProductSearchClient; +export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json new file mode 100644 index 00000000..8338e641 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p4beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts new file mode 100644 index 00000000..cb620c40 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts @@ -0,0 +1,848 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p4beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p4beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json new file mode 100644 index 00000000..e068ba98 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts new file mode 100644 index 00000000..d7092156 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts @@ -0,0 +1,2661 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p4beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of + * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, + * named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p4beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.create_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.get_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.update_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.create_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.get_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.update_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference + * image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.create_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.get_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this + * ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json new file mode 100644 index 00000000..518529b7 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json @@ -0,0 +1,120 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts new file mode 100644 index 00000000..e4af9d0b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts @@ -0,0 +1,693 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p4beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + 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); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts new file mode 100644 index 00000000..3ddcf07b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts @@ -0,0 +1,3100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p4beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p4beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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 productsearchModule.v1p4beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|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.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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: 'vision', + filename: './vision.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 593505170c291c6e96803408f8681060782d0a24 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 14 Sep 2022 20:20:21 +0000 Subject: [PATCH 6/9] =?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 --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 65 - .../google/cloud/vision/v1/geometry.proto | 68 - .../cloud/vision/v1/image_annotator.proto | 1044 ------ .../cloud/vision/v1/product_search.proto | 124 - .../vision/v1/product_search_service.proto | 1022 ------ .../cloud/vision/v1/text_annotation.proto | 258 -- .../cloud/vision/v1/web_detection.proto | 104 - ...ge_annotator.async_batch_annotate_files.js | 73 - ...e_annotator.async_batch_annotate_images.js | 78 - .../image_annotator.batch_annotate_files.js | 73 - .../image_annotator.batch_annotate_images.js | 72 - ...oduct_search.add_product_to_product_set.js | 70 - .../v1/product_search.create_product.js | 75 - .../v1/product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../v1/product_search.delete_product.js | 63 - .../v1/product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1/product_search.get_product.js | 63 - .../v1/product_search.get_product_set.js | 63 - .../v1/product_search.get_reference_image.js | 63 - .../v1/product_search.import_product_sets.js | 68 - .../v1/product_search.list_product_sets.js | 72 - .../v1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../v1/product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 70 - .../v1/product_search.update_product.js | 70 - .../v1/product_search.update_product_set.js | 68 - ...ippet_metadata.google.cloud.vision.v1.json | 1043 ------ owl-bot-staging/v1/src/index.ts | 27 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 -- .../v1/src/v1/image_annotator_client.ts | 921 ----- .../src/v1/image_annotator_client_config.json | 46 - .../v1/src/v1/image_annotator_proto_list.json | 8 - owl-bot-staging/v1/src/v1/index.ts | 20 - .../v1/src/v1/product_search_client.ts | 2654 -------------- .../src/v1/product_search_client_config.json | 121 - .../v1/src/v1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_image_annotator_v1.ts | 839 ----- .../v1/test/gapic_product_search_v1.ts | 3100 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1p1beta1/.eslintignore | 7 - owl-bot-staging/v1p1beta1/.eslintrc.json | 3 - owl-bot-staging/v1p1beta1/.gitignore | 14 - owl-bot-staging/v1p1beta1/.jsdoc.js | 55 - owl-bot-staging/v1p1beta1/.mocharc.js | 33 - owl-bot-staging/v1p1beta1/.prettierrc.js | 22 - owl-bot-staging/v1p1beta1/README.md | 1 - .../v1p1beta1/linkinator.config.json | 16 - owl-bot-staging/v1p1beta1/package.json | 64 - .../cloud/vision/v1p1beta1/geometry.proto | 53 - .../vision/v1p1beta1/image_annotator.proto | 618 ---- .../vision/v1p1beta1/text_annotation.proto | 251 -- .../vision/v1p1beta1/web_detection.proto | 103 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p1beta1.json | 55 - owl-bot-staging/v1p1beta1/src/index.ts | 25 - .../src/v1p1beta1/gapic_metadata.json | 33 - .../src/v1p1beta1/image_annotator_client.ts | 373 -- .../image_annotator_client_config.json | 31 - .../v1p1beta1/image_annotator_proto_list.json | 6 - .../v1p1beta1/src/v1p1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p1beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p1beta1.ts | 225 -- owl-bot-staging/v1p1beta1/tsconfig.json | 19 - owl-bot-staging/v1p1beta1/webpack.config.js | 64 - owl-bot-staging/v1p2beta1/.eslintignore | 7 - owl-bot-staging/v1p2beta1/.eslintrc.json | 3 - owl-bot-staging/v1p2beta1/.gitignore | 14 - owl-bot-staging/v1p2beta1/.jsdoc.js | 55 - owl-bot-staging/v1p2beta1/.mocharc.js | 33 - owl-bot-staging/v1p2beta1/.prettierrc.js | 22 - owl-bot-staging/v1p2beta1/README.md | 1 - .../v1p2beta1/linkinator.config.json | 16 - owl-bot-staging/v1p2beta1/package.json | 64 - .../cloud/vision/v1p2beta1/geometry.proto | 67 - .../vision/v1p2beta1/image_annotator.proto | 794 ----- .../vision/v1p2beta1/text_annotation.proto | 258 -- .../vision/v1p2beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p2beta1.json | 95 - owl-bot-staging/v1p2beta1/src/index.ts | 25 - .../src/v1p2beta1/gapic_metadata.json | 43 - .../src/v1p2beta1/image_annotator_client.ts | 492 --- .../image_annotator_client_config.json | 36 - .../v1p2beta1/image_annotator_proto_list.json | 6 - .../v1p2beta1/src/v1p2beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p2beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p2beta1.ts | 355 -- owl-bot-staging/v1p2beta1/tsconfig.json | 19 - owl-bot-staging/v1p2beta1/webpack.config.js | 64 - owl-bot-staging/v1p3beta1/.eslintignore | 7 - owl-bot-staging/v1p3beta1/.eslintrc.json | 3 - owl-bot-staging/v1p3beta1/.gitignore | 14 - owl-bot-staging/v1p3beta1/.jsdoc.js | 55 - owl-bot-staging/v1p3beta1/.mocharc.js | 33 - owl-bot-staging/v1p3beta1/.prettierrc.js | 22 - owl-bot-staging/v1p3beta1/README.md | 1 - .../v1p3beta1/linkinator.config.json | 16 - owl-bot-staging/v1p3beta1/package.json | 65 - .../cloud/vision/v1p3beta1/geometry.proto | 68 - .../vision/v1p3beta1/image_annotator.proto | 833 ----- .../vision/v1p3beta1/product_search.proto | 124 - .../v1p3beta1/product_search_service.proto | 971 ------ .../vision/v1p3beta1/text_annotation.proto | 258 -- .../vision/v1p3beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p3beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p3beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - ..._search.remove_product_from_product_set.js | 70 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p3beta1.json | 891 ----- owl-bot-staging/v1p3beta1/src/index.ts | 27 - .../src/v1p3beta1/gapic_metadata.json | 253 -- .../src/v1p3beta1/image_annotator_client.ts | 671 ---- .../image_annotator_client_config.json | 36 - .../v1p3beta1/image_annotator_proto_list.json | 8 - .../v1p3beta1/src/v1p3beta1/index.ts | 20 - .../src/v1p3beta1/product_search_client.ts | 2538 -------------- .../product_search_client_config.json | 116 - .../v1p3beta1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p3beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p3beta1.ts | 504 --- .../test/gapic_product_search_v1p3beta1.ts | 2946 ---------------- owl-bot-staging/v1p3beta1/tsconfig.json | 19 - owl-bot-staging/v1p3beta1/webpack.config.js | 64 - owl-bot-staging/v1p4beta1/.eslintignore | 7 - owl-bot-staging/v1p4beta1/.eslintrc.json | 3 - owl-bot-staging/v1p4beta1/.gitignore | 14 - owl-bot-staging/v1p4beta1/.jsdoc.js | 55 - owl-bot-staging/v1p4beta1/.mocharc.js | 33 - owl-bot-staging/v1p4beta1/.prettierrc.js | 22 - owl-bot-staging/v1p4beta1/README.md | 1 - .../v1p4beta1/linkinator.config.json | 16 - owl-bot-staging/v1p4beta1/package.json | 65 - .../google/cloud/vision/v1p4beta1/face.proto | 60 - .../cloud/vision/v1p4beta1/geometry.proto | 70 - .../vision/v1p4beta1/image_annotator.proto | 967 ----- .../vision/v1p4beta1/product_search.proto | 127 - .../v1p4beta1/product_search_service.proto | 1039 ------ .../vision/v1p4beta1/text_annotation.proto | 260 -- .../vision/v1p4beta1/web_detection.proto | 106 - ...ge_annotator.async_batch_annotate_files.js | 62 - ...e_annotator.async_batch_annotate_images.js | 67 - .../image_annotator.batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 77 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p4beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p4beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 71 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ------ owl-bot-staging/v1p4beta1/src/index.ts | 27 - .../src/v1p4beta1/gapic_metadata.json | 283 -- .../src/v1p4beta1/image_annotator_client.ts | 848 ----- .../image_annotator_client_config.json | 46 - .../v1p4beta1/image_annotator_proto_list.json | 9 - .../v1p4beta1/src/v1p4beta1/index.ts | 20 - .../src/v1p4beta1/product_search_client.ts | 2661 -------------- .../product_search_client_config.json | 120 - .../v1p4beta1/product_search_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p4beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p4beta1.ts | 693 ---- .../test/gapic_product_search_v1p4beta1.ts | 3100 ----------------- owl-bot-staging/v1p4beta1/tsconfig.json | 19 - owl-bot-staging/v1p4beta1/webpack.config.js | 64 - src/v1/image_annotator_client.ts | 8 +- src/v1/product_search_client.ts | 54 +- src/v1p3beta1/product_search_client.ts | 52 +- src/v1p4beta1/product_search_client.ts | 54 +- test/gapic_image_annotator_v1.ts | 411 +-- test/gapic_image_annotator_v1p1beta1.ts | 33 +- test/gapic_image_annotator_v1p2beta1.ts | 57 +- test/gapic_image_annotator_v1p3beta1.ts | 57 +- test/gapic_image_annotator_v1p4beta1.ts | 99 +- test/gapic_product_search_v1.ts | 1984 ++++++----- test/gapic_product_search_v1p3beta1.ts | 1876 +++++----- test/gapic_product_search_v1p4beta1.ts | 1984 ++++++----- 230 files changed, 3404 insertions(+), 47678 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1p1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p1beta1/.gitignore delete mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p1beta1/README.md delete mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p1beta1/package.json delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json delete mode 100644 owl-bot-staging/v1p1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p2beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p2beta1/.gitignore delete mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p2beta1/README.md delete mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p2beta1/package.json delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json delete mode 100644 owl-bot-staging/v1p2beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts delete mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p3beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p3beta1/.gitignore delete mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p3beta1/README.md delete mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p3beta1/package.json delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json delete mode 100644 owl-bot-staging/v1p3beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p4beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p4beta1/.gitignore delete mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p4beta1/README.md delete mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p4beta1/package.json delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json delete mode 100644 owl-bot-staging/v1p4beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto deleted file mode 100644 index 7e0d24c2..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto deleted file mode 100644 index 6fed6112..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto +++ /dev/null @@ -1,1044 +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.vision.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search.proto"; -import "google/cloud/vision/v1/text_annotation.proto"; -import "google/cloud/vision/v1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1/images:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1/files:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/images:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/files:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateImages requests. It does - // not work for AsyncBatchAnnotateImages requests. - bytes content = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - - // Left cheek center. - LEFT_CHEEK_CENTER = 35; - - // Right cheek center. - RIGHT_CHEEK_CENTER = 36; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only one - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 3; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto deleted file mode 100644 index a2a98505..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto deleted file mode 100644 index 65680d90..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto +++ /dev/null @@ -1,1022 +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.vision.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/vision/v1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or - // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are - // still supported, but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1.Product.product_category], and the - // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a - // space (" "). You can update the `display_name` later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto deleted file mode 100644 index 9c07c322..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto +++ /dev/null @@ -1,258 +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.vision.v1; - -import "google/cloud/vision/v1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more -// detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto deleted file mode 100644 index 369a1350..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 7d7ed138..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 70be298e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 528c4d1f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 2f57a691..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js deleted file mode 100644 index 1826ada2..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js deleted file mode 100644 index 9e064a95..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { - // [START vision_v1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js deleted file mode 100644 index 5c580189..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js deleted file mode 100644 index 6175cef1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js deleted file mode 100644 index 8d58541b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js deleted file mode 100644 index 5c5b8125..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js deleted file mode 100644 index 18a64743..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js deleted file mode 100644 index 27e014db..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js deleted file mode 100644 index fa80ab00..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js deleted file mode 100644 index b25fb5e6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js deleted file mode 100644 index 859e0f5a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js deleted file mode 100644 index 66a071b0..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js deleted file mode 100644 index 8fa795f6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js deleted file mode 100644 index 3e9871fc..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js deleted file mode 100644 index f7175d39..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js deleted file mode 100644 index 0dae0b9b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js deleted file mode 100644 index ad66ef6b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js deleted file mode 100644 index d8fd49f9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js deleted file mode 100644 index 26bf5ed6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json deleted file mode 100644 index def101a1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1.OutputConfig" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 67a41d87..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /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. ** - -import * as v1 from './v1'; -const ImageAnnotatorClient = v1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1.ImageAnnotatorClient; -const ProductSearchClient = v1.ProductSearchClient; -type ProductSearchClient = v1.ProductSearchClient; -export {v1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 13fb1dac..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts deleted file mode 100644 index 3fef9c7b..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client.ts +++ /dev/null @@ -1,921 +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/v1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. - * 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/image_annotator.batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. - * 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/image_annotator.batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - 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.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - 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.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json deleted file mode 100644 index 08f87df9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts deleted file mode 100644 index dc96f48b..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client.ts +++ /dev/null @@ -1,2654 +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} 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/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.create_product_set.js - * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.get_product_set.js - * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.update_product_set.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product_set.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.create_product.js - * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.get_product.js - * region_tag:vision_v1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.update_product.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.create_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.get_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.add_product_to_product_set.js - * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products.js - * region_tag:vision_v1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js - * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products_in_product_set.js - * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json deleted file mode 100644 index b7db1b90..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client_config.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts deleted file mode 100644 index e1102cdb..00000000 --- a/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts +++ /dev/null @@ -1,839 +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 imageannotatorModule 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('v1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - 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.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts deleted file mode 100644 index b8aa68c4..00000000 --- a/owl-bot-staging/v1/test/gapic_product_search_v1.ts +++ /dev/null @@ -1,3100 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1.ProductSearchClient({ - 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 productsearchModule.v1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|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.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'vision', - filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p1beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json deleted file mode 100644 index a08f8678..00000000 --- a/owl-bot-staging/v1p1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto deleted file mode 100644 index 6d46d9c3..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// 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 bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto deleted file mode 100644 index f66ad504..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ /dev/null @@ -1,618 +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.vision.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p1beta1/geometry.proto"; -import "google/cloud/vision/v1p1beta1/text_annotation.proto"; -import "google/cloud/vision/v1p1beta1/web_detection.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p1beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } -} - -// Users describe the type of Google Cloud Vision API tasks to perform over -// images by using *Feature*s. Each Feature indicates a type of image -// detection task to perform. Features encode the Cloud Vision API -// vertical to operate on and the number of top-scoring results to return. -message Feature { - // Type of image feature. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run OCR. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run computer vision models to compute image safe-search properties. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage image location). -message ImageSource { - // NOTE: For new code `image_uri` below is preferred. - // Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - string gcs_image_uri = 1; - - // Image URI which supports: - // 1) Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - // 2) Publicly accessible image HTTP/HTTPS URL. - // This is preferred over the legacy `gcs_image_uri` above. When both - // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location. If both `content` and `source` - // are provided for an image, `content` takes precedence and is - // used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // lat/long rectangle that specifies the location of the image. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto deleted file mode 100644 index f85cc44d..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -import "google/cloud/vision/v1p1beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width in pixels. - int32 width = 2; - - // Page height in pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto deleted file mode 100644 index c50e1ad6..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index eb0fe422..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json deleted file mode 100644 index dbece339..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p1beta1", - "version": "v1p1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts deleted file mode 100644 index 1137dce5..00000000 --- a/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; -const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -export {v1p1beta1, ImageAnnotatorClient}; -export default {v1p1beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json deleted file mode 100644 index 2dc79630..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts deleted file mode 100644 index 092acab0..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts +++ /dev/null @@ -1,373 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1p1beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p1beta1 - */ -export class ImageAnnotatorClient { - 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}; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p1beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. - * 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/v1p1beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json deleted file mode 100644 index 469fb95c..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p1beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json deleted file mode 100644 index 35609fc8..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts deleted file mode 100644 index cbaef061..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts +++ /dev/null @@ -1,225 +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 imageannotatorModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1p1beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p1beta1/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: 'vision', - filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p2beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p2beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json deleted file mode 100644 index a08f8678..00000000 --- a/owl-bot-staging/v1p2beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto deleted file mode 100644 index e9fec20b..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto deleted file mode 100644 index 264462d4..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ /dev/null @@ -1,794 +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.vision.v1p2beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p2beta1/geometry.proto"; -import "google/cloud/vision/v1p2beta1/text_annotation.proto"; -import "google/cloud/vision/v1p2beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p2beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run async image detection and annotation for a list of generic files (e.g. - // PDF) which may contain multiple pages and multiple images per page. - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p2beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file on GCS. - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a GCS - // object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto deleted file mode 100644 index af568194..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -import "google/cloud/vision/v1p2beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto deleted file mode 100644 index 2decb859..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 92074c3a..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 793ec83e..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json deleted file mode 100644 index c843af75..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p2beta1", - "version": "v1p2beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts deleted file mode 100644 index 0e8fea74..00000000 --- a/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; -const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -export {v1p2beta1, ImageAnnotatorClient}; -export default {v1p2beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json deleted file mode 100644 index 116ff853..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts deleted file mode 100644 index 399a91e4..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts +++ /dev/null @@ -1,492 +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/v1p2beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p2beta1 - */ -export class ImageAnnotatorClient { - 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; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p2beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. - * 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/v1p2beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run async image detection and annotation for a list of generic files (e.g. - * PDF) which may contain multiple pages and multiple images per page. - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json deleted file mode 100644 index 367627eb..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p2beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json deleted file mode 100644 index 2b5904f9..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts deleted file mode 100644 index 5c8ad8dc..00000000 --- a/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts +++ /dev/null @@ -1,355 +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 imageannotatorModule 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('v1p2beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p2beta1/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: 'vision', - filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p3beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p3beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1p3beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto deleted file mode 100644 index c2c524fb..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto deleted file mode 100644 index ebab14a6..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ /dev/null @@ -1,833 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search.proto"; -import "google/cloud/vision/v1p3beta1/text_annotation.proto"; -import "google/cloud/vision/v1p3beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p3beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = - 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto deleted file mode 100644 index 86ea1a06..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1p3beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto deleted file mode 100644 index daf1d0dd..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto +++ /dev/null @@ -1,971 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. All Products and ReferenceImages in the - // ProductSet will be deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only display_name, description and labels can be updated right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - // - // Possible errors: - // - // * Returns NOT_FOUND if the product does not exist. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the reference image does not exist. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND If the Product is not found under the ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories - // "homegoods", "apparel", and "toys" are still supported, but these should - // not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 100 product_labels. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this field is 0. - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 6 columns. - // 1. image_uri - // 2, image_id - // 3. product_set_id - // 4. product_id - // 5, product_category - // 6, product_display_name - // 7, labels - // 8. bounding_poly - // - // Columns 1, 3, 4, and 5 are required, other columns are optional. A new - // ProductSet/Product with the same id will be created on the fly - // if the ProductSet/Product specified by product_set_id/product_id does not - // exist. - // - // The image_id field is optional but has to be unique if provided. If it is - // empty, we will automatically assign an unique id to the image. - // - // The product_display_name field is optional. If it is empty, a space (" ") - // is used as the place holder for the product display_name, which can - // be updated later through the realtime API. - // - // If the Product with product_id already exists, the fields - // product_display_name, product_category and labels are ignored. - // - // If a Product doesn't exist and needs to be created on the fly, the - // product_display_name field refers to - // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], - // the product_category field refers to - // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], - // and the labels field refers to [Product.labels][]. - // - // Labels (optional) should be a line containing a list of comma-separated - // key-value pairs, with the format - // "key_1=value_1,key_2=value_2,...,key_n=value_n". - // - // The bounding_poly (optional) field is used to identify one region of - // interest from the image in the same manner as CreateReferenceImage. If no - // bounding_poly is specified, the system will try to detect regions of - // interest automatically. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 20MP). - // - // Also note that at most one bounding_poly is allowed per line. If the image - // contains multiple regions of interest, the csv should contain one line per - // region of interest. - // - // The bounding_poly column should contain an even number of comma-separated - // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative - // integers should be used for absolute bounding polygons, and float values - // in [0, 1] should be used for normalized bounding polygons. - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto deleted file mode 100644 index 633e404e..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -import "google/cloud/vision/v1p3beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto deleted file mode 100644 index 205dfe65..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 900c1b0b..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 1b58eca1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Individual image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index 96b4c8ba..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js deleted file mode 100644 index ed6ac1b8..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js deleted file mode 100644 index 90879035..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js deleted file mode 100644 index 48848360..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js deleted file mode 100644 index a5872042..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js deleted file mode 100644 index 7d971bc3..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js deleted file mode 100644 index c97f2727..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js deleted file mode 100644 index c62e8ea6..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js deleted file mode 100644 index 4def76dc..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js deleted file mode 100644 index 93ee9d82..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js deleted file mode 100644 index 23698c04..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js deleted file mode 100644 index 52033c07..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js deleted file mode 100644 index 454672d1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 65bc35e2..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js deleted file mode 100644 index 9deb4e05..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index 45dcddaf..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js deleted file mode 100644 index 8d98838c..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js deleted file mode 100644 index cfecdb70..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json deleted file mode 100644 index 90042759..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p3beta1", - "version": "v1p3beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts deleted file mode 100644 index 9e656a03..00000000 --- a/owl-bot-staging/v1p3beta1/src/index.ts +++ /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. ** - -import * as v1p3beta1 from './v1p3beta1'; -const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p3beta1.ProductSearchClient; -type ProductSearchClient = v1p3beta1.ProductSearchClient; -export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json deleted file mode 100644 index 52ae14a4..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p3beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts deleted file mode 100644 index 2114aa92..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts +++ /dev/null @@ -1,671 +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/v1p3beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p3beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. - * 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/v1p3beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json deleted file mode 100644 index 75a2b706..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts deleted file mode 100644 index facd3967..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts +++ /dev/null @@ -1,2538 +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} 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/v1p3beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p3beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.create_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.get_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.update_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. All Products and ReferenceImages in the - * ProductSet will be deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.create_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.get_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only display_name, description and labels can be updated right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.update_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * Possible errors: - * - * * Returns NOT_FOUND if the product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.create_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the reference image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.get_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND If the Product is not found under the ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json deleted file mode 100644 index ddc1e9ad..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts deleted file mode 100644 index 7e683838..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts +++ /dev/null @@ -1,504 +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 imageannotatorModule 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('v1p3beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts deleted file mode 100644 index 5fd1b0bd..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts +++ /dev/null @@ -1,2946 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p3beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p3beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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 productsearchModule.v1p3beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p3beta1/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: 'vision', - filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p4beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p4beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1p4beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto deleted file mode 100644 index d2ab72f0..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto +++ /dev/null @@ -1,60 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "CelebrityProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a celebrity recognition request. -message FaceRecognitionParams { - // The resource names for one or more - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity - // set is preloaded and can be specified as "builtin/default". If this is - // specified, the algorithm will try to match the faces detected in the input - // image to the Celebrities in the CelebritySets. - repeated string celebrity_set = 1; -} - -// A Celebrity is a group of Faces with an identity. -message Celebrity { - // The resource name of the preloaded Celebrity. Has the format - // `builtin/{mid}`. - string name = 1; - - // The Celebrity's display name. - string display_name = 2; - - // The Celebrity's description. - string description = 3; -} - -// Information about a face's identity. -message FaceRecognitionResult { - // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was - // matched to. - Celebrity celebrity = 1; - - // Recognition confidence. Range [0, 1]. - float confidence = 2; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto deleted file mode 100644 index 877fd897..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto +++ /dev/null @@ -1,70 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto deleted file mode 100644 index cc783697..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ /dev/null @@ -1,967 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p4beta1/face.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search.proto"; -import "google/cloud/vision/v1p4beta1/text_annotation.proto"; -import "google/cloud/vision/v1p4beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) - returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/files:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/images:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; - - // Additional recognition information. Only computed if - // image_context.face_recognition_params is provided, **and** a match is found - // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is - // sorted in order of decreasing confidence values. - repeated FaceRecognitionResult recognition_result = 16; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for face recognition. - FaceRecognitionParams face_recognition_params = 10; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only - // one AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto deleted file mode 100644 index ebb428ac..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto +++ /dev/null @@ -1,127 +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.vision.v1p4beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a - // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for - // similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto deleted file mode 100644 index df7bc7a3..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto +++ /dev/null @@ -1,1039 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of -// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of -// [Product][google.cloud.vision.v1p4beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of -// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, -// named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) - returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = - "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. - // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The - // legacy categories "homegoods", "apparel", and "toys" are still supported, - // but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference - // image. If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference - // image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this - // ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], - // and the `labels` column refers to - // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] - // field for the product to a space (" "). You can update the `display_name` - // later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto deleted file mode 100644 index 233c4c68..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto +++ /dev/null @@ -1,260 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto deleted file mode 100644 index 7d716570..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto +++ /dev/null @@ -1,106 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 199be36a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 8cb5197f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 2fe101f3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index f6aaa34e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index c6ef04f0..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js deleted file mode 100644 index 60ec6540..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js deleted file mode 100644 index ea4c348b..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js deleted file mode 100644 index bb6709c3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, referenceImage) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference - * image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js deleted file mode 100644 index 63f362dc..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js deleted file mode 100644 index 72ac7fec..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js deleted file mode 100644 index 92f9f39c..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js deleted file mode 100644 index 80db0f5a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js deleted file mode 100644 index acba73c5..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js deleted file mode 100644 index 5dc13d64..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js deleted file mode 100644 index 3a422698..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js deleted file mode 100644 index 81e409fa..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js deleted file mode 100644 index 8b67070e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 869b118f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js deleted file mode 100644 index 637c1f8a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js deleted file mode 100644 index 5dd66449..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index af9e9c14..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,71 +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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this - * ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js deleted file mode 100644 index 3c8d60bb..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js deleted file mode 100644 index 6ceb8322..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json deleted file mode 100644 index 65c6af72..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json +++ /dev/null @@ -1,1027 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p4beta1", - "version": "v1p4beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1p4beta1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts deleted file mode 100644 index 464f947a..00000000 --- a/owl-bot-staging/v1p4beta1/src/index.ts +++ /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. ** - -import * as v1p4beta1 from './v1p4beta1'; -const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p4beta1.ProductSearchClient; -type ProductSearchClient = v1p4beta1.ProductSearchClient; -export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json deleted file mode 100644 index 8338e641..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p4beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts deleted file mode 100644 index cb620c40..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts +++ /dev/null @@ -1,848 +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/v1p4beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p4beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json deleted file mode 100644 index e068ba98..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts deleted file mode 100644 index d7092156..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts +++ /dev/null @@ -1,2661 +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} 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/v1p4beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of - * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, - * named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p4beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.create_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.get_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.update_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.create_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.get_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.update_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference - * image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.create_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.get_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this - * ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json deleted file mode 100644 index 518529b7..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts deleted file mode 100644 index e4af9d0b..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts +++ /dev/null @@ -1,693 +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 imageannotatorModule 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('v1p4beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - 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); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts deleted file mode 100644 index 3ddcf07b..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts +++ /dev/null @@ -1,3100 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p4beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p4beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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 productsearchModule.v1p4beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|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.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p4beta1/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: 'vision', - filename: './vision.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/src/v1/image_annotator_client.ts b/src/v1/image_annotator_client.ts index be9af4e5..31495ea2 100644 --- a/src/v1/image_annotator_client.ts +++ b/src/v1/image_annotator_client.ts @@ -487,7 +487,7 @@ export class ImageAnnotatorClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchAnnotateImages(request, options, callback); @@ -598,7 +598,7 @@ export class ImageAnnotatorClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchAnnotateFiles(request, options, callback); @@ -725,7 +725,7 @@ export class ImageAnnotatorClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.asyncBatchAnnotateImages( @@ -885,7 +885,7 @@ export class ImageAnnotatorClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.asyncBatchAnnotateFiles( diff --git a/src/v1/product_search_client.ts b/src/v1/product_search_client.ts index 8e8cc2a8..1a64fc9e 100644 --- a/src/v1/product_search_client.ts +++ b/src/v1/product_search_client.ts @@ -534,7 +534,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProductSet(request, options, callback); @@ -626,7 +626,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProductSet(request, options, callback); @@ -723,7 +723,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -814,7 +814,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProductSet(request, options, callback); @@ -916,7 +916,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProduct(request, options, callback); @@ -1006,7 +1006,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProduct(request, options, callback); @@ -1112,7 +1112,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1204,7 +1204,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProduct(request, options, callback); @@ -1324,7 +1324,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createReferenceImage(request, options, callback); @@ -1424,7 +1424,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteReferenceImage(request, options, callback); @@ -1522,7 +1522,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getReferenceImage(request, options, callback); @@ -1628,7 +1628,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.addProductToProductSet( @@ -1737,7 +1737,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.removeProductFromProductSet( @@ -1859,7 +1859,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.importProductSets(request, options, callback); @@ -2030,7 +2030,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeProducts(request, options, callback); @@ -2164,7 +2164,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProductSets(request, options, callback); @@ -2204,7 +2204,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2253,7 +2253,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2358,7 +2358,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProducts(request, options, callback); @@ -2399,7 +2399,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2449,7 +2449,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2565,7 +2565,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listReferenceImages(request, options, callback); @@ -2609,7 +2609,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2662,7 +2662,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2775,7 +2775,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.listProductsInProductSet( @@ -2820,7 +2820,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2870,7 +2870,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1p3beta1/product_search_client.ts b/src/v1p3beta1/product_search_client.ts index 72350986..f309bbfe 100644 --- a/src/v1p3beta1/product_search_client.ts +++ b/src/v1p3beta1/product_search_client.ts @@ -518,7 +518,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProductSet(request, options, callback); @@ -616,7 +616,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProductSet(request, options, callback); @@ -719,7 +719,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -820,7 +820,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProductSet(request, options, callback); @@ -928,7 +928,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProduct(request, options, callback); @@ -1026,7 +1026,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProduct(request, options, callback); @@ -1137,7 +1137,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1239,7 +1239,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProduct(request, options, callback); @@ -1365,7 +1365,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createReferenceImage(request, options, callback); @@ -1476,7 +1476,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteReferenceImage(request, options, callback); @@ -1581,7 +1581,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getReferenceImage(request, options, callback); @@ -1693,7 +1693,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.addProductToProductSet( @@ -1806,7 +1806,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.removeProductFromProductSet( @@ -1928,7 +1928,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.importProductSets(request, options, callback); @@ -2068,7 +2068,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProductSets(request, options, callback); @@ -2108,7 +2108,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2157,7 +2157,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2268,7 +2268,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProducts(request, options, callback); @@ -2309,7 +2309,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2359,7 +2359,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2475,7 +2475,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listReferenceImages(request, options, callback); @@ -2519,7 +2519,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2572,7 +2572,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2685,7 +2685,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.listProductsInProductSet( @@ -2730,7 +2730,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2780,7 +2780,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1p4beta1/product_search_client.ts b/src/v1p4beta1/product_search_client.ts index 64850bd1..dd6eaab4 100644 --- a/src/v1p4beta1/product_search_client.ts +++ b/src/v1p4beta1/product_search_client.ts @@ -534,7 +534,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProductSet(request, options, callback); @@ -632,7 +632,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProductSet(request, options, callback); @@ -735,7 +735,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -832,7 +832,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProductSet(request, options, callback); @@ -940,7 +940,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createProduct(request, options, callback); @@ -1038,7 +1038,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getProduct(request, options, callback); @@ -1150,7 +1150,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1248,7 +1248,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteProduct(request, options, callback); @@ -1375,7 +1375,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createReferenceImage(request, options, callback); @@ -1482,7 +1482,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteReferenceImage(request, options, callback); @@ -1587,7 +1587,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getReferenceImage(request, options, callback); @@ -1699,7 +1699,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.addProductToProductSet( @@ -1809,7 +1809,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.removeProductFromProductSet( @@ -1931,7 +1931,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.importProductSets(request, options, callback); @@ -2102,7 +2102,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeProducts(request, options, callback); @@ -2242,7 +2242,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProductSets(request, options, callback); @@ -2282,7 +2282,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2331,7 +2331,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2442,7 +2442,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listProducts(request, options, callback); @@ -2483,7 +2483,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2533,7 +2533,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2649,7 +2649,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listReferenceImages(request, options, callback); @@ -2693,7 +2693,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2746,7 +2746,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2859,7 +2859,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.listProductsInProductSet( @@ -2904,7 +2904,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2954,7 +2954,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_image_annotator_v1.ts b/test/gapic_image_annotator_v1.ts index 21d764f9..ee671d31 100644 --- a/test/gapic_image_annotator_v1.ts +++ b/test/gapic_image_annotator_v1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule 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 @@ -191,15 +206,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() ); @@ -207,11 +218,14 @@ describe('v1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -223,15 +237,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() ); @@ -254,11 +264,14 @@ describe('v1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages with error', async () => { @@ -270,26 +283,25 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -301,7 +313,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.batchAnnotateImages(request), expectedError); @@ -318,15 +333,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() ); @@ -334,11 +345,14 @@ describe('v1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateFiles(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles without error using callback', async () => { @@ -350,15 +364,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() ); @@ -381,11 +391,14 @@ describe('v1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles with error', async () => { @@ -397,26 +410,25 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateFiles = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles with closed client', async () => { @@ -428,7 +440,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.batchAnnotateFiles(request), expectedError); @@ -445,15 +460,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -462,11 +474,14 @@ describe('v1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateImages(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages without error using callback', async () => { @@ -478,15 +493,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -516,11 +528,14 @@ describe('v1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages with call error', async () => { @@ -532,15 +547,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -550,11 +562,14 @@ describe('v1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateImages(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages with LRO error', async () => { @@ -566,15 +581,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -583,11 +595,14 @@ describe('v1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateImages(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { @@ -643,15 +658,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -660,11 +672,14 @@ describe('v1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -676,15 +691,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -714,11 +726,14 @@ describe('v1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -730,15 +745,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -748,11 +760,14 @@ describe('v1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -764,15 +779,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -781,11 +793,14 @@ describe('v1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p1beta1.ts b/test/gapic_image_annotator_v1p1beta1.ts index e701a3e8..edf4055b 100644 --- a/test/gapic_image_annotator_v1p1beta1.ts +++ b/test/gapic_image_annotator_v1p1beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -159,7 +174,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() ); @@ -167,11 +181,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -183,7 +192,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() ); @@ -206,11 +214,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -222,18 +225,12 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { diff --git a/test/gapic_image_annotator_v1p2beta1.ts b/test/gapic_image_annotator_v1p2beta1.ts index d1ea965f..8ddfa624 100644 --- a/test/gapic_image_annotator_v1p2beta1.ts +++ b/test/gapic_image_annotator_v1p2beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule 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 @@ -191,7 +206,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -302,11 +298,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -318,7 +309,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -348,11 +338,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -364,7 +349,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -374,11 +358,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -390,7 +369,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -399,11 +377,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p3beta1.ts b/test/gapic_image_annotator_v1p3beta1.ts index 329d8b3d..b82c3419 100644 --- a/test/gapic_image_annotator_v1p3beta1.ts +++ b/test/gapic_image_annotator_v1p3beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule 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 @@ -191,7 +206,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -302,11 +298,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -318,7 +309,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -348,11 +338,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -364,7 +349,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -374,11 +358,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -390,7 +369,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -399,11 +377,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p4beta1.ts b/test/gapic_image_annotator_v1p4beta1.ts index 37e06f60..97a633c9 100644 --- a/test/gapic_image_annotator_v1p4beta1.ts +++ b/test/gapic_image_annotator_v1p4beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule 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 @@ -191,7 +206,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() ); @@ -301,11 +297,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateFiles(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateFiles without error using callback', async () => { @@ -317,7 +308,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() ); @@ -340,11 +330,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateFiles with error', async () => { @@ -356,18 +341,12 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateFiles = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateFiles with closed client', async () => { @@ -395,7 +374,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -404,11 +382,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateImages(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateImages without error using callback', async () => { @@ -420,7 +393,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -450,11 +422,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateImages with call error', async () => { @@ -466,7 +433,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -476,11 +442,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateImages(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateImages with LRO error', async () => { @@ -492,7 +453,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -501,11 +461,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateImages(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { @@ -561,7 +516,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -570,11 +524,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -586,7 +535,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -616,11 +564,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -632,7 +575,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -642,11 +584,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -658,7 +595,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -667,11 +603,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_product_search_v1.ts b/test/gapic_product_search_v1.ts index ac4d6486..d0d1388a 100644 --- a/test/gapic_product_search_v1.ts +++ b/test/gapic_product_search_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +299,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -316,11 +326,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +345,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +375,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +395,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +425,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -442,11 +452,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +471,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +501,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +521,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +553,13 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -570,11 +582,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +601,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +633,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +655,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +685,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +712,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +731,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +761,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +781,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +811,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -824,11 +838,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +857,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +887,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +907,23 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +935,9 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -950,11 +960,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +979,23 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1007,8 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1025,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1057,13 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -1078,11 +1086,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1105,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1137,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1159,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1189,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1216,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1235,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1265,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1285,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1286,11 +1297,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1316,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1333,11 +1343,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1362,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1392,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1412,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1424,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1443,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1470,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1489,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1519,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1539,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1569,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1586,11 +1596,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1615,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1645,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1665,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1678,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1697,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1725,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1744,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1759,14 @@ describe('v1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1778,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1802,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1815,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1834,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1862,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1881,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1896,14 @@ describe('v1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1915,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1939,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1952,14 @@ describe('v1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +1971,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2005,14 @@ describe('v1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2024,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2054,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2067,14 @@ describe('v1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2129,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2127,11 +2142,14 @@ describe('v1.ProductSearchClient', () => { const [operation] = await client.purgeProducts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts without error using callback', async () => { @@ -2143,15 +2161,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2181,11 +2195,14 @@ describe('v1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with call error', async () => { @@ -2197,26 +2214,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeProducts(request), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with LRO error', async () => { @@ -2228,15 +2244,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, @@ -2245,11 +2257,14 @@ describe('v1.ProductSearchClient', () => { ); const [operation] = await client.purgeProducts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeProductsProgress without error', async () => { @@ -2304,15 +2319,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2321,11 +2332,14 @@ describe('v1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2337,15 +2351,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2370,11 +2380,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2386,26 +2399,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2417,8 +2429,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2449,11 +2464,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2466,8 +2482,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2493,11 +2512,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2510,8 +2530,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2531,11 +2554,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2548,8 +2572,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2566,11 +2593,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2585,15 +2613,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2602,11 +2626,14 @@ describe('v1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2618,15 +2645,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2651,11 +2674,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2667,26 +2693,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2698,8 +2723,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2727,11 +2755,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2744,8 +2773,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2770,11 +2802,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2787,8 +2820,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2808,11 +2844,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2825,8 +2862,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2843,11 +2883,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2862,15 +2903,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -2886,11 +2923,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2902,15 +2942,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -2941,11 +2977,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -2957,26 +2996,25 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -2988,8 +3026,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -3026,11 +3067,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3043,8 +3085,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3070,11 +3115,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3087,8 +3133,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -3114,11 +3163,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3131,8 +3181,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3149,11 +3202,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3168,15 +3222,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3186,11 +3237,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3202,15 +3256,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3235,11 +3286,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3251,15 +3305,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3269,11 +3320,14 @@ describe('v1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3285,8 +3339,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3317,12 +3375,15 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3335,8 +3396,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3362,12 +3427,15 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3380,8 +3448,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3402,12 +3474,15 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3420,8 +3495,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3439,12 +3518,15 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_product_search_v1p3beta1.ts b/test/gapic_product_search_v1p3beta1.ts index adad0827..6d515af9 100644 --- a/test/gapic_product_search_v1p3beta1.ts +++ b/test/gapic_product_search_v1p3beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +299,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -316,11 +326,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +345,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +375,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +395,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +425,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -442,11 +452,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +471,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +501,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +521,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +553,13 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -570,11 +582,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +601,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +633,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +655,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +685,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +712,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +731,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +761,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +781,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +811,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -824,11 +838,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +857,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +887,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +907,23 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +935,9 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -950,11 +960,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +979,23 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1007,8 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1025,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1057,13 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -1078,11 +1086,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1105,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1137,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1159,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1189,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1216,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1235,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1265,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1285,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1286,11 +1297,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1316,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1333,11 +1343,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1362,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1392,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1412,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1424,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1443,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1470,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1489,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1519,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1539,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1569,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1586,11 +1596,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1615,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1645,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1665,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1678,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1697,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1725,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1744,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1759,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1778,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1802,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1815,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1834,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1862,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1881,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1896,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1915,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1939,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1952,14 @@ describe('v1p3beta1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +1971,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2005,14 @@ describe('v1p3beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2024,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2054,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2067,14 @@ describe('v1p3beta1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2129,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2133,11 +2148,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2149,15 +2167,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2188,11 +2202,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2204,26 +2221,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2235,8 +2251,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2273,11 +2292,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2290,8 +2310,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2317,11 +2340,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2334,8 +2358,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2361,11 +2388,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2378,8 +2406,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2397,11 +2428,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2416,15 +2448,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2439,11 +2467,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2455,15 +2486,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2494,11 +2521,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2510,26 +2540,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2541,8 +2570,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2579,11 +2611,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2596,8 +2629,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2625,11 +2661,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2642,8 +2679,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2669,11 +2709,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2686,8 +2727,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2704,11 +2748,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2723,15 +2768,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2747,11 +2788,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2763,15 +2807,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2804,11 +2844,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -2820,26 +2863,25 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -2851,8 +2893,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2890,11 +2935,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2907,8 +2953,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2935,11 +2984,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2952,8 +3002,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2980,11 +3033,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2997,8 +3051,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3016,11 +3073,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3035,15 +3093,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3059,11 +3114,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3075,15 +3133,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3114,11 +3169,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3130,15 +3188,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3148,11 +3203,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3164,8 +3222,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3205,12 +3267,15 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3223,8 +3288,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3253,12 +3322,15 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3271,8 +3343,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3299,12 +3375,15 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3317,8 +3396,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3336,12 +3419,15 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_product_search_v1p4beta1.ts b/test/gapic_product_search_v1p4beta1.ts index 538ec6e0..059393a8 100644 --- a/test/gapic_product_search_v1p4beta1.ts +++ b/test/gapic_product_search_v1p4beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +299,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -316,11 +326,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +345,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +375,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +395,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +425,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -442,11 +452,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +471,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +501,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +521,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +553,13 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -570,11 +582,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +601,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +633,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ + 'productSet', + 'name', + ]); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +655,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +685,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +712,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +731,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +761,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +781,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +811,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -824,11 +838,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +857,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +887,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +907,23 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +935,9 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -950,11 +960,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +979,23 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1007,8 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1025,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1057,13 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -1078,11 +1086,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1105,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1137,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ + 'product', + 'name', + ]); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1159,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1189,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1216,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1235,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1265,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1285,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1286,11 +1297,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1316,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1333,11 +1343,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1362,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1392,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1412,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1424,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1443,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1470,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1489,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1519,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1539,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1569,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1586,11 +1596,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1615,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1645,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1665,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1678,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1697,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1725,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1744,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1759,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1778,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1802,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1815,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1834,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1862,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1881,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1896,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1915,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1939,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1952,14 @@ describe('v1p4beta1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +1971,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2005,14 @@ describe('v1p4beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2024,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2054,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2067,14 @@ describe('v1p4beta1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2129,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2127,11 +2142,14 @@ describe('v1p4beta1.ProductSearchClient', () => { const [operation] = await client.purgeProducts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts without error using callback', async () => { @@ -2143,15 +2161,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2181,11 +2195,14 @@ describe('v1p4beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with call error', async () => { @@ -2197,26 +2214,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeProducts(request), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with LRO error', async () => { @@ -2228,15 +2244,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, @@ -2245,11 +2257,14 @@ describe('v1p4beta1.ProductSearchClient', () => { ); const [operation] = await client.purgeProducts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeProductsProgress without error', async () => { @@ -2304,15 +2319,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2327,11 +2338,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2343,15 +2357,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2382,11 +2392,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2398,26 +2411,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2429,8 +2441,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2467,11 +2482,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2484,8 +2500,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2511,11 +2530,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2528,8 +2548,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2555,11 +2578,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2572,8 +2596,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2591,11 +2618,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2610,15 +2638,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2633,11 +2657,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2649,15 +2676,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2688,11 +2711,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2704,26 +2730,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2735,8 +2760,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2773,11 +2801,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2790,8 +2819,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2819,11 +2851,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2836,8 +2869,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2863,11 +2899,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2880,8 +2917,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2898,11 +2938,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2917,15 +2958,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -2941,11 +2978,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2957,15 +2997,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -2998,11 +3034,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -3014,26 +3053,25 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -3045,8 +3083,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -3084,11 +3125,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3101,8 +3143,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3129,11 +3174,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3146,8 +3192,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -3174,11 +3223,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3191,8 +3241,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3210,11 +3263,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3229,15 +3283,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3253,11 +3304,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3269,15 +3323,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3308,11 +3359,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3324,15 +3378,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3342,11 +3393,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3358,8 +3412,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3399,12 +3457,15 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3417,8 +3478,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3447,12 +3512,15 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3465,8 +3533,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3493,12 +3565,15 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3511,8 +3586,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + 'ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3530,12 +3609,15 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); From d82b58804b5768a55434685fdef8a8f84f0153ec Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 21 Sep 2022 02:04:31 +0000 Subject: [PATCH 7/9] test: use fully qualified request type name in tests PiperOrigin-RevId: 475685359 Source-Link: https://github.com/googleapis/googleapis/commit/7a129736313ceb1f277c3b7f7e16d2e04cc901dd Source-Link: https://github.com/googleapis/googleapis-gen/commit/370c729e2ba062a167449c27882ba5f379c5c34d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzcwYzcyOWUyYmEwNjJhMTY3NDQ5YzI3ODgyYmE1ZjM3OWM1YzM0ZCJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 65 + .../google/cloud/vision/v1/geometry.proto | 68 + .../cloud/vision/v1/image_annotator.proto | 1044 ++++++ .../cloud/vision/v1/product_search.proto | 124 + .../vision/v1/product_search_service.proto | 1022 ++++++ .../cloud/vision/v1/text_annotation.proto | 258 ++ .../cloud/vision/v1/web_detection.proto | 104 + ...ge_annotator.async_batch_annotate_files.js | 73 + ...e_annotator.async_batch_annotate_images.js | 78 + .../image_annotator.batch_annotate_files.js | 73 + .../image_annotator.batch_annotate_images.js | 72 + ...oduct_search.add_product_to_product_set.js | 70 + .../v1/product_search.create_product.js | 75 + .../v1/product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../v1/product_search.delete_product.js | 63 + .../v1/product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1/product_search.get_product.js | 63 + .../v1/product_search.get_product_set.js | 63 + .../v1/product_search.get_reference_image.js | 63 + .../v1/product_search.import_product_sets.js | 68 + .../v1/product_search.list_product_sets.js | 72 + .../v1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../v1/product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 70 + .../v1/product_search.update_product.js | 70 + .../v1/product_search.update_product_set.js | 68 + ...ippet_metadata.google.cloud.vision.v1.json | 1043 ++++++ owl-bot-staging/v1/src/index.ts | 27 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 ++ .../v1/src/v1/image_annotator_client.ts | 921 +++++ .../src/v1/image_annotator_client_config.json | 46 + .../v1/src/v1/image_annotator_proto_list.json | 8 + owl-bot-staging/v1/src/v1/index.ts | 20 + .../v1/src/v1/product_search_client.ts | 2654 ++++++++++++++ .../src/v1/product_search_client_config.json | 121 + .../v1/src/v1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_image_annotator_v1.ts | 839 +++++ .../v1/test/gapic_product_search_v1.ts | 3100 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1p1beta1/.eslintignore | 7 + owl-bot-staging/v1p1beta1/.eslintrc.json | 3 + owl-bot-staging/v1p1beta1/.gitignore | 14 + owl-bot-staging/v1p1beta1/.jsdoc.js | 55 + owl-bot-staging/v1p1beta1/.mocharc.js | 33 + owl-bot-staging/v1p1beta1/.prettierrc.js | 22 + owl-bot-staging/v1p1beta1/README.md | 1 + .../v1p1beta1/linkinator.config.json | 16 + owl-bot-staging/v1p1beta1/package.json | 64 + .../cloud/vision/v1p1beta1/geometry.proto | 53 + .../vision/v1p1beta1/image_annotator.proto | 618 ++++ .../vision/v1p1beta1/text_annotation.proto | 251 ++ .../vision/v1p1beta1/web_detection.proto | 103 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p1beta1.json | 55 + owl-bot-staging/v1p1beta1/src/index.ts | 25 + .../src/v1p1beta1/gapic_metadata.json | 33 + .../src/v1p1beta1/image_annotator_client.ts | 373 ++ .../image_annotator_client_config.json | 31 + .../v1p1beta1/image_annotator_proto_list.json | 6 + .../v1p1beta1/src/v1p1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p1beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p1beta1.ts | 225 ++ owl-bot-staging/v1p1beta1/tsconfig.json | 19 + owl-bot-staging/v1p1beta1/webpack.config.js | 64 + owl-bot-staging/v1p2beta1/.eslintignore | 7 + owl-bot-staging/v1p2beta1/.eslintrc.json | 3 + owl-bot-staging/v1p2beta1/.gitignore | 14 + owl-bot-staging/v1p2beta1/.jsdoc.js | 55 + owl-bot-staging/v1p2beta1/.mocharc.js | 33 + owl-bot-staging/v1p2beta1/.prettierrc.js | 22 + owl-bot-staging/v1p2beta1/README.md | 1 + .../v1p2beta1/linkinator.config.json | 16 + owl-bot-staging/v1p2beta1/package.json | 64 + .../cloud/vision/v1p2beta1/geometry.proto | 67 + .../vision/v1p2beta1/image_annotator.proto | 794 +++++ .../vision/v1p2beta1/text_annotation.proto | 258 ++ .../vision/v1p2beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...etadata.google.cloud.vision.v1p2beta1.json | 95 + owl-bot-staging/v1p2beta1/src/index.ts | 25 + .../src/v1p2beta1/gapic_metadata.json | 43 + .../src/v1p2beta1/image_annotator_client.ts | 492 +++ .../image_annotator_client_config.json | 36 + .../v1p2beta1/image_annotator_proto_list.json | 6 + .../v1p2beta1/src/v1p2beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1p2beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p2beta1.ts | 355 ++ owl-bot-staging/v1p2beta1/tsconfig.json | 19 + owl-bot-staging/v1p2beta1/webpack.config.js | 64 + owl-bot-staging/v1p3beta1/.eslintignore | 7 + owl-bot-staging/v1p3beta1/.eslintrc.json | 3 + owl-bot-staging/v1p3beta1/.gitignore | 14 + owl-bot-staging/v1p3beta1/.jsdoc.js | 55 + owl-bot-staging/v1p3beta1/.mocharc.js | 33 + owl-bot-staging/v1p3beta1/.prettierrc.js | 22 + owl-bot-staging/v1p3beta1/README.md | 1 + .../v1p3beta1/linkinator.config.json | 16 + owl-bot-staging/v1p3beta1/package.json | 65 + .../cloud/vision/v1p3beta1/geometry.proto | 68 + .../vision/v1p3beta1/image_annotator.proto | 833 +++++ .../vision/v1p3beta1/product_search.proto | 124 + .../v1p3beta1/product_search_service.proto | 971 ++++++ .../vision/v1p3beta1/text_annotation.proto | 258 ++ .../vision/v1p3beta1/web_detection.proto | 103 + ...ge_annotator.async_batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 76 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p3beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p3beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + ..._search.remove_product_from_product_set.js | 70 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p3beta1.json | 891 +++++ owl-bot-staging/v1p3beta1/src/index.ts | 27 + .../src/v1p3beta1/gapic_metadata.json | 253 ++ .../src/v1p3beta1/image_annotator_client.ts | 671 ++++ .../image_annotator_client_config.json | 36 + .../v1p3beta1/image_annotator_proto_list.json | 8 + .../v1p3beta1/src/v1p3beta1/index.ts | 20 + .../src/v1p3beta1/product_search_client.ts | 2538 ++++++++++++++ .../product_search_client_config.json | 116 + .../v1p3beta1/product_search_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p3beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p3beta1.ts | 504 +++ .../test/gapic_product_search_v1p3beta1.ts | 2946 ++++++++++++++++ owl-bot-staging/v1p3beta1/tsconfig.json | 19 + owl-bot-staging/v1p3beta1/webpack.config.js | 64 + owl-bot-staging/v1p4beta1/.eslintignore | 7 + owl-bot-staging/v1p4beta1/.eslintrc.json | 3 + owl-bot-staging/v1p4beta1/.gitignore | 14 + owl-bot-staging/v1p4beta1/.jsdoc.js | 55 + owl-bot-staging/v1p4beta1/.mocharc.js | 33 + owl-bot-staging/v1p4beta1/.prettierrc.js | 22 + owl-bot-staging/v1p4beta1/README.md | 1 + .../v1p4beta1/linkinator.config.json | 16 + owl-bot-staging/v1p4beta1/package.json | 65 + .../google/cloud/vision/v1p4beta1/face.proto | 60 + .../cloud/vision/v1p4beta1/geometry.proto | 70 + .../vision/v1p4beta1/image_annotator.proto | 967 +++++ .../vision/v1p4beta1/product_search.proto | 127 + .../v1p4beta1/product_search_service.proto | 1039 ++++++ .../vision/v1p4beta1/text_annotation.proto | 260 ++ .../vision/v1p4beta1/web_detection.proto | 106 + ...ge_annotator.async_batch_annotate_files.js | 62 + ...e_annotator.async_batch_annotate_images.js | 67 + .../image_annotator.batch_annotate_files.js | 62 + .../image_annotator.batch_annotate_images.js | 61 + ...oduct_search.add_product_to_product_set.js | 70 + .../product_search.create_product.js | 75 + .../product_search.create_product_set.js | 74 + .../product_search.create_reference_image.js | 77 + .../product_search.delete_product.js | 63 + .../product_search.delete_product_set.js | 63 + .../product_search.delete_reference_image.js | 63 + .../v1p4beta1/product_search.get_product.js | 63 + .../product_search.get_product_set.js | 63 + .../product_search.get_reference_image.js | 63 + .../product_search.import_product_sets.js | 68 + .../product_search.list_product_sets.js | 72 + .../v1p4beta1/product_search.list_products.js | 73 + ...uct_search.list_products_in_product_set.js | 73 + .../product_search.list_reference_images.js | 75 + .../product_search.purge_products.js | 77 + ..._search.remove_product_from_product_set.js | 71 + .../product_search.update_product.js | 70 + .../product_search.update_product_set.js | 68 + ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ++++++ owl-bot-staging/v1p4beta1/src/index.ts | 27 + .../src/v1p4beta1/gapic_metadata.json | 283 ++ .../src/v1p4beta1/image_annotator_client.ts | 848 +++++ .../image_annotator_client_config.json | 46 + .../v1p4beta1/image_annotator_proto_list.json | 9 + .../v1p4beta1/src/v1p4beta1/index.ts | 20 + .../src/v1p4beta1/product_search_client.ts | 2661 ++++++++++++++ .../product_search_client_config.json | 120 + .../v1p4beta1/product_search_proto_list.json | 9 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p4beta1/system-test/install.ts | 49 + .../test/gapic_image_annotator_v1p4beta1.ts | 693 ++++ .../test/gapic_product_search_v1p4beta1.ts | 3100 +++++++++++++++++ owl-bot-staging/v1p4beta1/tsconfig.json | 19 + owl-bot-staging/v1p4beta1/webpack.config.js | 64 + 218 files changed, 44413 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts create mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1p1beta1/.eslintignore create mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p1beta1/.gitignore create mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p1beta1/README.md create mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p1beta1/package.json create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json create mode 100644 owl-bot-staging/v1p1beta1/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p2beta1/.eslintignore create mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p2beta1/.gitignore create mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p2beta1/README.md create mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p2beta1/package.json create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json create mode 100644 owl-bot-staging/v1p2beta1/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts create mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p3beta1/.eslintignore create mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p3beta1/.gitignore create mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p3beta1/README.md create mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p3beta1/package.json create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json create mode 100644 owl-bot-staging/v1p3beta1/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts create mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js create mode 100644 owl-bot-staging/v1p4beta1/.eslintignore create mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p4beta1/.gitignore create mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p4beta1/README.md create mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p4beta1/package.json create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto create mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js create mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json create mode 100644 owl-bot-staging/v1p4beta1/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json create mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts create mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto new file mode 100644 index 00000000..7e0d24c2 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto new file mode 100644 index 00000000..6fed6112 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto @@ -0,0 +1,1044 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search.proto"; +import "google/cloud/vision/v1/text_annotation.proto"; +import "google/cloud/vision/v1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1/images:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1/files:annotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:annotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:annotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/images:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/files:asyncBatchAnnotate" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" + body: "*" + } + additional_bindings { + post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateImages requests. It does + // not work for AsyncBatchAnnotateImages requests. + bytes content = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + + // Left cheek center. + LEFT_CHEEK_CENTER = 35; + + // Right cheek center. + RIGHT_CHEEK_CENTER = 36; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 3; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no parent is specified, a region will be chosen automatically. + // + // Supported location-ids: + // `us`: USA country only, + // `asia`: East asia areas, like Japan, Taiwan, + // `eu`: The European Union. + // + // Example: `projects/project-A/locations/eu`. + string parent = 4; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto new file mode 100644 index 00000000..a2a98505 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1/geometry.proto"; +import "google/cloud/vision/v1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto new file mode 100644 index 00000000..65680d90 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto @@ -0,0 +1,1022 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.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/vision/v1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + // progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or + // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are + // still supported, but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1.Product.product_category], and the + // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a + // space (" "). You can update the `display_name` later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto new file mode 100644 index 00000000..9c07c322 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +import "google/cloud/vision/v1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more +// detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto new file mode 100644 index 00000000..369a1350 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..7d7ed138 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..70be298e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..528c4d1f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..2f57a691 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Optional. Target project and location to make a call. + * Format: `projects/{project-id}/locations/{location-id}`. + * If no parent is specified, a region will be chosen automatically. + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * Example: `projects/project-A/locations/eu`. + */ + // const parent = 'abc123' + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..1826ada2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js new file mode 100644 index 00000000..9e064a95 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { + // [START vision_v1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js new file mode 100644 index 00000000..5c580189 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js new file mode 100644 index 00000000..6175cef1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js new file mode 100644 index 00000000..8d58541b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js new file mode 100644 index 00000000..5c5b8125 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js new file mode 100644 index 00000000..18a64743 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js new file mode 100644 index 00000000..27e014db --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js new file mode 100644 index 00000000..fa80ab00 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js new file mode 100644 index 00000000..b25fb5e6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js new file mode 100644 index 00000000..859e0f5a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js new file mode 100644 index 00000000..66a071b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js new file mode 100644 index 00000000..8fa795f6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..3e9871fc --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js new file mode 100644 index 00000000..f7175d39 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js new file mode 100644 index 00000000..0dae0b9b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..ad66ef6b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js new file mode 100644 index 00000000..d8fd49f9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js new file mode 100644 index 00000000..26bf5ed6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json new file mode 100644 index 00000000..def101a1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json @@ -0,0 +1,1043 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1.OutputConfig" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..67a41d87 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const ImageAnnotatorClient = v1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1.ImageAnnotatorClient; +const ProductSearchClient = v1.ProductSearchClient; +type ProductSearchClient = v1.ProductSearchClient; +export {v1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..13fb1dac --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts new file mode 100644 index 00000000..3fef9c7b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client.ts @@ -0,0 +1,921 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. + * 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/image_annotator.batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * 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/image_annotator.batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, + 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.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {string} request.parent + * Optional. Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no parent is specified, a region will be chosen automatically. + * + * Supported location-ids: + * `us`: USA country only, + * `asia`: East asia areas, like Japan, Taiwan, + * `eu`: The European Union. + * + * Example: `projects/project-A/locations/eu`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, + 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.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json new file mode 100644 index 00000000..08f87df9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts new file mode 100644 index 00000000..dc96f48b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client.ts @@ -0,0 +1,2654 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.create_product_set.js + * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.get_product_set.js + * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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/product_search.update_product_set.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet, + protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product_set.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.create_product.js + * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.get_product.js + * region_tag:vision_v1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.update_product.js + * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IProduct, + protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_product.js + * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.create_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.delete_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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/product_search.get_reference_image.js + * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage, + protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.add_product_to_product_set.js + * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/product_search.import_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/product_search.purge_products.js + * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductSetsRequest, + protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1.IProductSet[], + protos.google.cloud.vision.v1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js + * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsRequest, + protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsRequest|null, + protos.google.cloud.vision.v1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products.js + * region_tag:vision_v1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1.IReferenceImage[], + protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js + * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1.IProduct[], + protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/product_search.list_products_in_product_set.js + * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json new file mode 100644 index 00000000..b7db1b90 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_client_config.json @@ -0,0 +1,121 @@ +{ + "interfaces": { + "google.cloud.vision.v1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json new file mode 100644 index 00000000..0d468bf9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1/geometry.proto", + "../../protos/google/cloud/vision/v1/image_annotator.proto", + "../../protos/google/cloud/vision/v1/product_search.proto", + "../../protos/google/cloud/vision/v1/product_search_service.proto", + "../../protos/google/cloud/vision/v1/text_annotation.proto", + "../../protos/google/cloud/vision/v1/web_detection.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts new file mode 100644 index 00000000..269cf78a --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts @@ -0,0 +1,839 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + 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.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts new file mode 100644 index 00000000..5527a23b --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_product_search_v1.ts @@ -0,0 +1,3100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1.ProductSearchClient({ + 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 productsearchModule.v1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|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.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'vision', + filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json new file mode 100644 index 00000000..a08f8678 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto new file mode 100644 index 00000000..6d46d9c3 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// 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 bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto new file mode 100644 index 00000000..f66ad504 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -0,0 +1,618 @@ +// 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.vision.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p1beta1/geometry.proto"; +import "google/cloud/vision/v1p1beta1/text_annotation.proto"; +import "google/cloud/vision/v1p1beta1/web_detection.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p1beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } +} + +// Users describe the type of Google Cloud Vision API tasks to perform over +// images by using *Feature*s. Each Feature indicates a type of image +// detection task to perform. Features encode the Cloud Vision API +// vertical to operate on and the number of top-scoring results to return. +message Feature { + // Type of image feature. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run OCR. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run computer vision models to compute image safe-search properties. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage image location). +message ImageSource { + // NOTE: For new code `image_uri` below is preferred. + // Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + string gcs_image_uri = 1; + + // Image URI which supports: + // 1) Google Cloud Storage image URI, which must be in the following form: + // `gs://bucket_name/object_name` (for details, see + // [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris)). + // NOTE: Cloud Storage object versioning is not supported. + // 2) Publicly accessible image HTTP/HTTPS URL. + // This is preferred over the legacy `gcs_image_uri` above. When both + // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location. If both `content` and `source` + // are provided for an image, `content` takes precedence and is + // used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // lat/long rectangle that specifies the location of the image. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto new file mode 100644 index 00000000..f85cc44d --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto @@ -0,0 +1,251 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + +import "google/cloud/vision/v1p1beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width in pixels. + int32 width = 2; + + // Page height in pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto new file mode 100644 index 00000000..c50e1ad6 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p1beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p1beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..eb0fe422 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json new file mode 100644 index 00000000..dbece339 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json @@ -0,0 +1,55 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p1beta1", + "version": "v1p1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts new file mode 100644 index 00000000..1137dce5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; +const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; +export {v1p1beta1, ImageAnnotatorClient}; +export default {v1p1beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json new file mode 100644 index 00000000..2dc79630 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts new file mode 100644 index 00000000..092acab0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p1beta1 + */ +export class ImageAnnotatorClient { + 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}; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p1beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. + * 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/v1p1beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json new file mode 100644 index 00000000..469fb95c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.vision.v1p1beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..35609fc8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts new file mode 100644 index 00000000..cbaef061 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts @@ -0,0 +1,225 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1p1beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p1beta1/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: 'vision', + filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json new file mode 100644 index 00000000..a08f8678 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto new file mode 100644 index 00000000..e9fec20b --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto @@ -0,0 +1,67 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto new file mode 100644 index 00000000..264462d4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -0,0 +1,794 @@ +// 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.vision.v1p2beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p2beta1/geometry.proto"; +import "google/cloud/vision/v1p2beta1/text_annotation.proto"; +import "google/cloud/vision/v1p2beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p2beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run async image detection and annotation for a list of generic files (e.g. + // PDF) which may contain multiple pages and multiple images per page. + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p2beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file on GCS. + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a GCS + // object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto new file mode 100644 index 00000000..af568194 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + +import "google/cloud/vision/v1p2beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto new file mode 100644 index 00000000..2decb859 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p2beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p2beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..92074c3a --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..793ec83e --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json new file mode 100644 index 00000000..c843af75 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json @@ -0,0 +1,95 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p2beta1", + "version": "v1p2beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts new file mode 100644 index 00000000..0e8fea74 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; +const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; +export {v1p2beta1, ImageAnnotatorClient}; +export default {v1p2beta1, ImageAnnotatorClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json new file mode 100644 index 00000000..116ff853 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts new file mode 100644 index 00000000..399a91e4 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts @@ -0,0 +1,492 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p2beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p2beta1 + */ +export class ImageAnnotatorClient { + 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; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p2beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. + * 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/v1p2beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run async image detection and annotation for a list of generic files (e.g. + * PDF) which may contain multiple pages and multiple images per page. + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json new file mode 100644 index 00000000..367627eb --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p2beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..2b5904f9 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts new file mode 100644 index 00000000..a9739874 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..cf73a1c5 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..bc529419 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); +} + +main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts new file mode 100644 index 00000000..5c8ad8dc --- /dev/null +++ b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts @@ -0,0 +1,355 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p2beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p2beta1/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: 'vision', + filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p3beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto new file mode 100644 index 00000000..c2c524fb --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto new file mode 100644 index 00000000..ebab14a6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -0,0 +1,833 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search.proto"; +import "google/cloud/vision/v1p3beta1/text_annotation.proto"; +import "google/cloud/vision/v1p3beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p3beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale, as returned in `ImageParams`. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale, as returned in `ImageParams`. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for product search. + google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = + 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. + repeated AnnotateImageResponse responses = 2; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // The type of the file. Currently only "application/pdf" and "image/tiff" + // are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI where the results will be stored. Results will + // be in JSON format and preceded by its corresponding input URI. This field + // can either represent a single file, or a prefix for multiple outputs. + // Prefixes must end in a `/`. + // + // Examples: + // + // * File: gs://bucket-name/filename.json + // * Prefix: gs://bucket-name/prefix/here/ + // * File: gs://bucket-name/prefix/here + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto new file mode 100644 index 00000000..86ea1a06 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/cloud/vision/v1p3beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto new file mode 100644 index 00000000..daf1d0dd --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto @@ -0,0 +1,971 @@ +// 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.vision.v1p3beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p3beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. All Products and ReferenceImages in the + // ProductSet will be deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only display_name, description and labels can be updated right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + // + // Possible errors: + // + // * Returns NOT_FOUND if the product does not exist. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the reference image does not exist. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND If the Product is not found under the ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. This should + // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories + // "homegoods", "apparel", and "toys" are still supported, but these should + // not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 100 product_labels. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this field is 0. + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference image. + // If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/Product" + } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 6 columns. + // 1. image_uri + // 2, image_id + // 3. product_set_id + // 4. product_id + // 5, product_category + // 6, product_display_name + // 7, labels + // 8. bounding_poly + // + // Columns 1, 3, 4, and 5 are required, other columns are optional. A new + // ProductSet/Product with the same id will be created on the fly + // if the ProductSet/Product specified by product_set_id/product_id does not + // exist. + // + // The image_id field is optional but has to be unique if provided. If it is + // empty, we will automatically assign an unique id to the image. + // + // The product_display_name field is optional. If it is empty, a space (" ") + // is used as the place holder for the product display_name, which can + // be updated later through the realtime API. + // + // If the Product with product_id already exists, the fields + // product_display_name, product_category and labels are ignored. + // + // If a Product doesn't exist and needs to be created on the fly, the + // product_display_name field refers to + // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], + // the product_category field refers to + // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], + // and the labels field refers to [Product.labels][]. + // + // Labels (optional) should be a line containing a list of comma-separated + // key-value pairs, with the format + // "key_1=value_1,key_2=value_2,...,key_n=value_n". + // + // The bounding_poly (optional) field is used to identify one region of + // interest from the image in the same manner as CreateReferenceImage. If no + // bounding_poly is specified, the system will try to detect regions of + // interest automatically. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 20MP). + // + // Also note that at most one bounding_poly is allowed per line. If the image + // contains multiple regions of interest, the csv should contain one line per + // region of interest. + // + // The bounding_poly column should contain an even number of comma-separated + // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative + // integers should be used for absolute bounding polygons, and float values + // in [0, 1] should be used for normalized bounding polygons. + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto new file mode 100644 index 00000000..633e404e --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto @@ -0,0 +1,258 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + +import "google/cloud/vision/v1p3beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertice order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto new file mode 100644 index 00000000..205dfe65 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto @@ -0,0 +1,103 @@ +// Copyright 2018 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.vision.v1p3beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p3beta1"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // Best guess text labels for the request image. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..900c1b0b --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..1b58eca1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Individual image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..96b4c8ba --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js new file mode 100644 index 00000000..ed6ac1b8 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js new file mode 100644 index 00000000..90879035 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..48848360 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js new file mode 100644 index 00000000..a5872042 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..7d971bc3 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..c97f2727 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js new file mode 100644 index 00000000..c62e8ea6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js new file mode 100644 index 00000000..4def76dc --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..93ee9d82 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..23698c04 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..52033c07 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js new file mode 100644 index 00000000..454672d1 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..65bc35e2 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..9deb4e05 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..45dcddaf --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js new file mode 100644 index 00000000..8d98838c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js new file mode 100644 index 00000000..cfecdb70 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json new file mode 100644 index 00000000..90042759 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json @@ -0,0 +1,891 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p3beta1", + "version": "v1p3beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p3beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p3beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts new file mode 100644 index 00000000..9e656a03 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p3beta1 from './v1p3beta1'; +const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p3beta1.ProductSearchClient; +type ProductSearchClient = v1p3beta1.ProductSearchClient; +export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json new file mode 100644 index 00000000..52ae14a4 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json @@ -0,0 +1,253 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p3beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts new file mode 100644 index 00000000..2114aa92 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts @@ -0,0 +1,671 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p3beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p3beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. + * 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/v1p3beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json new file mode 100644 index 00000000..75a2b706 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts new file mode 100644 index 00000000..facd3967 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts @@ -0,0 +1,2538 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p3beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p3beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p3beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.create_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.get_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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/v1p3beta1/product_search.update_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet, + protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. All Products and ReferenceImages in the + * ProductSet will be deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.create_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.get_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only display_name, description and labels can be updated right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p3beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.update_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct, + protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * Possible errors: + * + * * Returns NOT_FOUND if the product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_product.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.create_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the reference image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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/v1p3beta1/product_search.get_reference_image.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage, + protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND If the Product is not found under the ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p3beta1/product_search.import_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProductSet[], + protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IReferenceImage[], + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p3beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p3beta1.IProduct[], + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json new file mode 100644 index 00000000..ddc1e9ad --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json @@ -0,0 +1,116 @@ +{ + "interfaces": { + "google.cloud.vision.v1p3beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json new file mode 100644 index 00000000..f5f413b6 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts new file mode 100644 index 00000000..7e683838 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts @@ -0,0 +1,504 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p3beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts new file mode 100644 index 00000000..970736be --- /dev/null +++ b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts @@ -0,0 +1,2946 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p3beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p3beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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 productsearchModule.v1p3beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p3beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p3beta1/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: 'vision', + filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js new file mode 100644 index 00000000..3a185a84 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/vision', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md new file mode 100644 index 00000000..083a8d0a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/README.md @@ -0,0 +1 @@ +Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json new file mode 100644 index 00000000..19f15af4 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/vision", + "version": "0.1.0", + "description": "Vision client for Node.js", + "repository": "googleapis/nodejs-vision", + "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 vision", + "vision", + "image annotator", + "product search" + ], + "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.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@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/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto new file mode 100644 index 00000000..d2ab72f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto @@ -0,0 +1,60 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "CelebrityProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a celebrity recognition request. +message FaceRecognitionParams { + // The resource names for one or more + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity + // set is preloaded and can be specified as "builtin/default". If this is + // specified, the algorithm will try to match the faces detected in the input + // image to the Celebrities in the CelebritySets. + repeated string celebrity_set = 1; +} + +// A Celebrity is a group of Faces with an identity. +message Celebrity { + // The resource name of the preloaded Celebrity. Has the format + // `builtin/{mid}`. + string name = 1; + + // The Celebrity's display name. + string display_name = 2; + + // The Celebrity's description. + string description = 3; +} + +// Information about a face's identity. +message FaceRecognitionResult { + // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was + // matched to. + Celebrity celebrity = 1; + + // Recognition confidence. Range [0, 1]. + float confidence = 2; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto new file mode 100644 index 00000000..877fd897 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto @@ -0,0 +1,70 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// 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; +} + +// A 3D position in the image, used primarily for Face detection landmarks. +// A valid Position must have both x and y coordinates. +// The position coordinates are in the same scale as the original image. +message Position { + // X coordinate. + float x = 1; + + // Y coordinate. + float y = 2; + + // Z coordinate (or depth). + float z = 3; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto new file mode 100644 index 00000000..cc783697 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -0,0 +1,967 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/vision/v1p4beta1/face.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search.proto"; +import "google/cloud/vision/v1p4beta1/text_annotation.proto"; +import "google/cloud/vision/v1p4beta1/web_detection.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/latlng.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ImageAnnotatorProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Service that performs Google Cloud Vision API detection tasks over client +// images, such as face, landmark, logo, label, and text detection. The +// ImageAnnotator service returns detected entities from the images. +service ImageAnnotator { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Run image detection and annotation for a batch of images. + rpc BatchAnnotateImages(BatchAnnotateImagesRequest) + returns (BatchAnnotateImagesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/images:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) + returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1p4beta1/files:annotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/images:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests,output_config"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateImagesResponse" + metadata_type: "OperationMetadata" + }; + } + + // Run asynchronous image detection and annotation for a list of generic + // files, such as PDF files, which may contain multiple pages and multiple + // images per page. Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/files:asyncBatchAnnotate" + body: "*" + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "AsyncBatchAnnotateFilesResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// The type of Google Cloud Vision API detection to perform, and the maximum +// number of results to return for that type. Multiple `Feature` objects can +// be specified in the `features` list. +message Feature { + // Type of Google Cloud Vision API feature to be extracted. + enum Type { + // Unspecified feature type. + TYPE_UNSPECIFIED = 0; + + // Run face detection. + FACE_DETECTION = 1; + + // Run landmark detection. + LANDMARK_DETECTION = 2; + + // Run logo detection. + LOGO_DETECTION = 3; + + // Run label detection. + LABEL_DETECTION = 4; + + // Run text detection / optical character recognition (OCR). Text detection + // is optimized for areas of text within a larger image; if the image is + // a document, use `DOCUMENT_TEXT_DETECTION` instead. + TEXT_DETECTION = 5; + + // Run dense text document OCR. Takes precedence when both + // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. + DOCUMENT_TEXT_DETECTION = 11; + + // Run Safe Search to detect potentially unsafe + // or undesirable content. + SAFE_SEARCH_DETECTION = 6; + + // Compute a set of image properties, such as the + // image's dominant colors. + IMAGE_PROPERTIES = 7; + + // Run crop hints. + CROP_HINTS = 9; + + // Run web detection. + WEB_DETECTION = 10; + + // Run Product Search. + PRODUCT_SEARCH = 12; + + // Run localizer for object detection. + OBJECT_LOCALIZATION = 19; + } + + // The feature type. + Type type = 1; + + // Maximum number of results of this type. Does not apply to + // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. + int32 max_results = 2; + + // Model to use for the feature. + // Supported values: "builtin/stable" (the default if unset) and + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. + string model = 3; +} + +// External image source (Google Cloud Storage or web URL image location). +message ImageSource { + // **Use `image_uri` instead.** + // + // The 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 gcs_image_uri = 1; + + // The URI of the source image. Can be either: + // + // 1. A 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. + // + // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from + // HTTP/HTTPS URLs, Google cannot guarantee that the request will be + // completed. Your request may fail if the specified host denies the + // request (e.g. due to request throttling or DOS prevention), or if Google + // throttles requests to the site for abuse prevention. You should not + // depend on externally-hosted images for production applications. + // + // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes + // precedence. + string image_uri = 2; +} + +// Client image to perform Google Cloud Vision API tasks over. +message Image { + // Image 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 = 1; + + // Google Cloud Storage image location, or publicly-accessible image + // URL. If both `content` and `source` are provided for an image, `content` + // takes precedence and is used to perform the image annotation request. + ImageSource source = 2; +} + +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely. + VERY_UNLIKELY = 1; + + // It is unlikely. + UNLIKELY = 2; + + // It is possible. + POSSIBLE = 3; + + // It is likely. + LIKELY = 4; + + // It is very likely. + VERY_LIKELY = 5; +} + +// A face annotation object contains the results of face detection. +message FaceAnnotation { + // A face-specific landmark (for example, a face feature). + message Landmark { + // Face landmark (feature) type. + // Left and right are defined from the vantage of the viewer of the image + // without considering mirror projections typical of photos. So, `LEFT_EYE`, + // typically, is the person's right eye. + enum Type { + // Unknown face landmark detected. Should not be filled. + UNKNOWN_LANDMARK = 0; + + // Left eye. + LEFT_EYE = 1; + + // Right eye. + RIGHT_EYE = 2; + + // Left of left eyebrow. + LEFT_OF_LEFT_EYEBROW = 3; + + // Right of left eyebrow. + RIGHT_OF_LEFT_EYEBROW = 4; + + // Left of right eyebrow. + LEFT_OF_RIGHT_EYEBROW = 5; + + // Right of right eyebrow. + RIGHT_OF_RIGHT_EYEBROW = 6; + + // Midpoint between eyes. + MIDPOINT_BETWEEN_EYES = 7; + + // Nose tip. + NOSE_TIP = 8; + + // Upper lip. + UPPER_LIP = 9; + + // Lower lip. + LOWER_LIP = 10; + + // Mouth left. + MOUTH_LEFT = 11; + + // Mouth right. + MOUTH_RIGHT = 12; + + // Mouth center. + MOUTH_CENTER = 13; + + // Nose, bottom right. + NOSE_BOTTOM_RIGHT = 14; + + // Nose, bottom left. + NOSE_BOTTOM_LEFT = 15; + + // Nose, bottom center. + NOSE_BOTTOM_CENTER = 16; + + // Left eye, top boundary. + LEFT_EYE_TOP_BOUNDARY = 17; + + // Left eye, right corner. + LEFT_EYE_RIGHT_CORNER = 18; + + // Left eye, bottom boundary. + LEFT_EYE_BOTTOM_BOUNDARY = 19; + + // Left eye, left corner. + LEFT_EYE_LEFT_CORNER = 20; + + // Right eye, top boundary. + RIGHT_EYE_TOP_BOUNDARY = 21; + + // Right eye, right corner. + RIGHT_EYE_RIGHT_CORNER = 22; + + // Right eye, bottom boundary. + RIGHT_EYE_BOTTOM_BOUNDARY = 23; + + // Right eye, left corner. + RIGHT_EYE_LEFT_CORNER = 24; + + // Left eyebrow, upper midpoint. + LEFT_EYEBROW_UPPER_MIDPOINT = 25; + + // Right eyebrow, upper midpoint. + RIGHT_EYEBROW_UPPER_MIDPOINT = 26; + + // Left ear tragion. + LEFT_EAR_TRAGION = 27; + + // Right ear tragion. + RIGHT_EAR_TRAGION = 28; + + // Left eye pupil. + LEFT_EYE_PUPIL = 29; + + // Right eye pupil. + RIGHT_EYE_PUPIL = 30; + + // Forehead glabella. + FOREHEAD_GLABELLA = 31; + + // Chin gnathion. + CHIN_GNATHION = 32; + + // Chin left gonion. + CHIN_LEFT_GONION = 33; + + // Chin right gonion. + CHIN_RIGHT_GONION = 34; + } + + // Face landmark type. + Type type = 3; + + // Face landmark position. + Position position = 4; + } + + // The bounding polygon around the face. The coordinates of the bounding box + // are in the original image's scale. + // The bounding box is computed to "frame" the face in accordance with human + // expectations. It is based on the landmarker results. + // Note that one or more x and/or y coordinates may not be generated in the + // `BoundingPoly` (the polygon will be unbounded) if only a partial face + // appears in the image to be annotated. + BoundingPoly bounding_poly = 1; + + // The `fd_bounding_poly` bounding polygon is tighter than the + // `boundingPoly`, and encloses only the skin part of the face. Typically, it + // is used to eliminate the face from any image analysis that detects the + // "amount of skin" visible in an image. It is not based on the + // landmarker results, only on the initial face detection, hence + // the fd (face detection) prefix. + BoundingPoly fd_bounding_poly = 2; + + // Detected face landmarks. + repeated Landmark landmarks = 3; + + // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation + // of the face relative to the image vertical about the axis perpendicular to + // the face. Range [-180,180]. + float roll_angle = 4; + + // Yaw angle, which indicates the leftward/rightward angle that the face is + // pointing relative to the vertical plane perpendicular to the image. Range + // [-180,180]. + float pan_angle = 5; + + // Pitch angle, which indicates the upwards/downwards angle that the face is + // pointing relative to the image's horizontal plane. Range [-180,180]. + float tilt_angle = 6; + + // Detection confidence. Range [0, 1]. + float detection_confidence = 7; + + // Face landmarking confidence. Range [0, 1]. + float landmarking_confidence = 8; + + // Joy likelihood. + Likelihood joy_likelihood = 9; + + // Sorrow likelihood. + Likelihood sorrow_likelihood = 10; + + // Anger likelihood. + Likelihood anger_likelihood = 11; + + // Surprise likelihood. + Likelihood surprise_likelihood = 12; + + // Under-exposed likelihood. + Likelihood under_exposed_likelihood = 13; + + // Blurred likelihood. + Likelihood blurred_likelihood = 14; + + // Headwear likelihood. + Likelihood headwear_likelihood = 15; + + // Additional recognition information. Only computed if + // image_context.face_recognition_params is provided, **and** a match is found + // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input + // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is + // sorted in order of decreasing confidence values. + repeated FaceRecognitionResult recognition_result = 16; +} + +// Detected entity location information. +message LocationInfo { + // lat/long location coordinates. + google.type.LatLng lat_lng = 1; +} + +// A `Property` consists of a user-supplied name/value pair. +message Property { + // Name of the property. + string name = 1; + + // Value of the property. + string value = 2; + + // Value of numeric properties. + uint64 uint64_value = 3; +} + +// Set of detected entity features. +message EntityAnnotation { + // Opaque entity ID. Some IDs may be available in + // [Google Knowledge Graph Search + // API](https://developers.google.com/knowledge-graph/). + string mid = 1; + + // The language code for the locale in which the entity textual + // `description` is expressed. + string locale = 2; + + // Entity textual description, expressed in its `locale` language. + string description = 3; + + // Overall score of the result. Range [0, 1]. + float score = 4; + + // **Deprecated. Use `score` instead.** + // The accuracy of the entity detection in an image. + // For example, for an image in which the "Eiffel Tower" entity is detected, + // this field represents the confidence that there is a tower in the query + // image. Range [0, 1]. + float confidence = 5 [deprecated = true]; + + // The relevancy of the ICA (Image Content Annotation) label to the + // image. For example, the relevancy of "tower" is likely higher to an image + // containing the detected "Eiffel Tower" than to an image containing a + // detected distant towering building, even though the confidence that + // there is a tower in each image may be the same. Range [0, 1]. + float topicality = 6; + + // Image region to which this entity belongs. Not produced + // for `LABEL_DETECTION` features. + BoundingPoly bounding_poly = 7; + + // The location information for the detected entity. Multiple + // `LocationInfo` elements can be present because one location may + // indicate the location of the scene in the image, and another location + // may indicate the location of the place where the image was taken. + // Location information is usually present for landmarks. + repeated LocationInfo locations = 8; + + // Some entities may have optional user-supplied `Property` (name/value) + // fields, such a score or string that qualifies the entity. + repeated Property properties = 9; +} + +// Set of detected objects with bounding boxes. +message LocalizedObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + + // Image region to which this object belongs. This must be populated. + BoundingPoly bounding_poly = 5; +} + +// Set of features pertaining to the image, computed by computer vision +// methods over safe-search verticals (for example, adult, spoof, medical, +// violence). +message SafeSearchAnnotation { + // Represents the adult content likelihood for the image. Adult content may + // contain elements such as nudity, pornographic images or cartoons, or + // sexual activities. + Likelihood adult = 1; + + // Spoof likelihood. The likelihood that an modification + // was made to the image's canonical version to make it appear + // funny or offensive. + Likelihood spoof = 2; + + // Likelihood that this is a medical image. + Likelihood medical = 3; + + // Likelihood that this image contains violent content. + Likelihood violence = 4; + + // Likelihood that the request image contains racy content. Racy content may + // include (but is not limited to) skimpy or sheer clothing, strategically + // covered nudity, lewd or provocative poses, or close-ups of sensitive + // body areas. + Likelihood racy = 9; +} + +// Rectangle determined by min and max `LatLng` pairs. +message LatLongRect { + // Min lat/long pair. + google.type.LatLng min_lat_lng = 1; + + // Max lat/long pair. + google.type.LatLng max_lat_lng = 2; +} + +// Color information consists of RGB channels, score, and the fraction of +// the image that the color occupies in the image. +message ColorInfo { + // RGB components of the color. + google.type.Color color = 1; + + // Image-specific score for this color. Value in range [0, 1]. + float score = 2; + + // The fraction of pixels the color occupies in the image. + // Value in range [0, 1]. + float pixel_fraction = 3; +} + +// Set of dominant colors and their corresponding scores. +message DominantColorsAnnotation { + // RGB color values with their score and pixel fraction. + repeated ColorInfo colors = 1; +} + +// Stores image properties, such as dominant colors. +message ImageProperties { + // If present, dominant colors completed successfully. + DominantColorsAnnotation dominant_colors = 1; +} + +// Single crop hint that is used to generate a new crop when serving an image. +message CropHint { + // The bounding polygon for the crop region. The coordinates of the bounding + // box are in the original image's scale. + BoundingPoly bounding_poly = 1; + + // Confidence of this being a salient region. Range [0, 1]. + float confidence = 2; + + // Fraction of importance of this salient region with respect to the original + // image. + float importance_fraction = 3; +} + +// Set of crop hints that are used to generate new crops when serving images. +message CropHintsAnnotation { + // Crop hint results. + repeated CropHint crop_hints = 1; +} + +// Parameters for crop hints annotation request. +message CropHintsParams { + // Aspect ratios in floats, representing the ratio of the width to the height + // of the image. For example, if the desired aspect ratio is 4/3, the + // corresponding float value should be 1.33333. If not specified, the + // best possible crop is returned. The number of provided aspect ratios is + // limited to a maximum of 16; any aspect ratios provided after the 16th are + // ignored. + repeated float aspect_ratios = 1; +} + +// Parameters for web detection request. +message WebDetectionParams { + // Whether to include results derived from the geo information in the image. + bool include_geo_results = 2; +} + +// Parameters for text detections. This is used to control TEXT_DETECTION and +// DOCUMENT_TEXT_DETECTION features. +message TextDetectionParams { + + // By default, Cloud Vision API only includes confidence score for + // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence + // score for TEXT_DETECTION as well. + bool enable_text_detection_confidence_score = 9; + + // A list of advanced OCR options to fine-tune OCR behavior. + repeated string advanced_ocr_options = 11; +} + +// Image context and/or feature-specific parameters. +message ImageContext { + // Not used. + LatLongRect lat_long_rect = 1; + + // List of languages to use for TEXT_DETECTION. 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). Text detection returns an + // error if one or more of the specified languages is not one of the + // [supported languages](https://cloud.google.com/vision/docs/languages). + repeated string language_hints = 2; + + // Parameters for crop hints annotation request. + CropHintsParams crop_hints_params = 4; + + // Parameters for face recognition. + FaceRecognitionParams face_recognition_params = 10; + + // Parameters for product search. + ProductSearchParams product_search_params = 5; + + // Parameters for web detection. + WebDetectionParams web_detection_params = 6; + + // Parameters for text detection and document text detection. + TextDetectionParams text_detection_params = 12; +} + +// Request for performing Google Cloud Vision API tasks over a user-provided +// image, with user-requested features, and with context information. +message AnnotateImageRequest { + // The image to be processed. + Image image = 1; + + // Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image. + ImageContext image_context = 3; +} + +// If an image was produced from a file (e.g. a PDF), this message gives +// information about the source of that image. +message ImageAnnotationContext { + // The URI of the file used to produce the image. + string uri = 1; + + // If the file was a PDF or TIFF, this field gives the page number within + // the file used to produce the image. + int32 page_number = 2; +} + +// Response to an image annotation request. +message AnnotateImageResponse { + // If present, face detection has completed successfully. + repeated FaceAnnotation face_annotations = 1; + + // If present, landmark detection has completed successfully. + repeated EntityAnnotation landmark_annotations = 2; + + // If present, logo detection has completed successfully. + repeated EntityAnnotation logo_annotations = 3; + + // If present, label detection has completed successfully. + repeated EntityAnnotation label_annotations = 4; + + // If present, localized object detection has completed successfully. + // This will be sorted descending by confidence score. + repeated LocalizedObjectAnnotation localized_object_annotations = 22; + + // If present, text (OCR) detection has completed successfully. + repeated EntityAnnotation text_annotations = 5; + + // If present, text (OCR) detection or document (OCR) text detection has + // completed successfully. + // This annotation provides the structural hierarchy for the OCR detected + // text. + TextAnnotation full_text_annotation = 12; + + // If present, safe-search annotation has completed successfully. + SafeSearchAnnotation safe_search_annotation = 6; + + // If present, image properties were extracted successfully. + ImageProperties image_properties_annotation = 8; + + // If present, crop hints have completed successfully. + CropHintsAnnotation crop_hints_annotation = 11; + + // If present, web detection has completed successfully. + WebDetection web_detection = 13; + + // If present, product search has completed successfully. + ProductSearchResults product_search_results = 14; + + // If set, represents the error message for the operation. + // Note that filled-in image annotations are guaranteed to be + // correct, even when `error` is set. + google.rpc.Status error = 9; + + // If present, contextual information is needed to understand where this image + // comes from. + ImageAnnotationContext context = 21; +} + +// Multiple image annotation requests are batched into a single service call. +message BatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to a batch image annotation request. +message BatchAnnotateImagesResponse { + // Individual responses to image annotation requests within the batch. + repeated AnnotateImageResponse responses = 1; +} + +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// Response to a single file annotation request. A file may contain one or more +// images, which individually have their own responses. +message AnnotateFileResponse { + // Information about the file for which this response is generated. + InputConfig input_config = 1; + + // Individual responses to images found within the file. This field will be + // empty if the `error` field is set. + repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; + + // If set, represents the error message for the failed request. The + // `responses` field will not be set in this case. + google.rpc.Status error = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // Required. The list of file annotation requests. Right now we support only + // one AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + +// An offline file annotation request. +message AsyncAnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 4; +} + +// The response for a single offline file annotation request. +message AsyncAnnotateFileResponse { + // The output location and metadata from AsyncAnnotateFileRequest. + OutputConfig output_config = 1; +} + +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Required. Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + +// Multiple async file annotation requests are batched into a single service +// call. +message AsyncBatchAnnotateFilesRequest { + // Required. Individual async file annotation requests for this batch. + repeated AsyncAnnotateFileRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response to an async batch file annotation request. +message AsyncBatchAnnotateFilesResponse { + // The list of file annotation responses, one for each request in + // AsyncBatchAnnotateFilesRequest. + repeated AsyncAnnotateFileResponse responses = 1; +} + +// The desired input location and metadata. +message InputConfig { + // The Google Cloud Storage location to read the input from. + GcsSource gcs_source = 1; + + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + + // The type of the file. Currently only "application/pdf", "image/tiff" and + // "image/gif" are supported. Wildcards are not supported. + string mime_type = 2; +} + +// The desired output location and metadata. +message OutputConfig { + // The Google Cloud Storage location to write the output(s) to. + GcsDestination gcs_destination = 1; + + // The max number of response protos to put into each output JSON file 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 response protos will + // be generated. If `batch_size` = 20, then 5 json files each + // containing 20 response protos will be written under the prefix + // `gcs_destination`.`uri`. + // + // Currently, batch_size only applies to GcsDestination, with potential future + // support for other output configurations. + int32 batch_size = 2; +} + +// The Google Cloud Storage location where the input will be read from. +message GcsSource { + // Google Cloud Storage URI for the input file. This must only be a + // Google Cloud Storage object. Wildcards are not currently supported. + string uri = 1; +} + +// The Google Cloud Storage location where the output will be written to. +message GcsDestination { + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. + // + // Examples: + // + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. + // + // If multiple outputs, each response is still AnnotateFileResponse, each of + // which contains some subset of the full list of AnnotateImageResponse. + // Multiple outputs can happen if, for example, the output JSON is too large + // and overflows into multiple sharded files. + string uri = 1; +} + +// Contains metadata for the BatchAnnotateImages operation. +message OperationMetadata { + // Batch operation states. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is received. + CREATED = 1; + + // Request is actively being processed. + RUNNING = 2; + + // The batch processing is done. + DONE = 3; + + // The batch processing was cancelled. + CANCELLED = 4; + } + + // Current state of the batch operation. + State state = 1; + + // The time when the batch request was received. + google.protobuf.Timestamp create_time = 5; + + // The time when the operation result was last updated. + google.protobuf.Timestamp update_time = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto new file mode 100644 index 00000000..ebb428ac --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto @@ -0,0 +1,127 @@ +// 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.vision.v1p4beta1; + +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/cloud/vision/v1p4beta1/product_search_service.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Parameters for a product search request. +message ProductSearchParams { + // The bounding polygon around the area of interest in the image. + // If it is not specified, system discretion will be applied. + BoundingPoly bounding_poly = 9; + + // The resource name of a + // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for + // similar images. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + string product_set = 6 [(google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + }]; + + // The list of product categories to search in. Currently, we only consider + // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", + // "packagedgoods-v1", or "general-v1" should be specified. The legacy + // categories "homegoods", "apparel", and "toys" are still supported but will + // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", + // or "toys-v2" for better product search accuracy. It is recommended to + // migrate existing products to these categories as well. + repeated string product_categories = 7; + + // The filtering expression. This can be used to restrict search results based + // on Product labels. We currently support an AND of OR of key-value + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. + // + // For example, "(color = red OR color = blue) AND brand = Google" is + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. + string filter = 8; +} + +// Results for a product search request. +message ProductSearchResults { + // Information about a product. + message Result { + // The Product. + Product product = 1; + + // A confidence level on the match, ranging from 0 (no confidence) to + // 1 (full confidence). + float score = 2; + + // The resource name of the image from the product that is the closest match + // to the query. + string image = 3; + } + + // Prediction for what the object in the bounding box is. + message ObjectAnnotation { + // Object ID that should align with EntityAnnotation mid. + string mid = 1; + + // 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 = 2; + + // Object name, expressed in its `language_code` language. + string name = 3; + + // Score of the result. Range [0, 1]. + float score = 4; + } + + // Information about the products similar to a single product in a query + // image. + message GroupedResult { + // The bounding polygon around the product detected in the query image. + BoundingPoly bounding_poly = 1; + + // List of results, one for each product match. + repeated Result results = 2; + + // List of generic predictions for the object in the bounding box. + repeated ObjectAnnotation object_annotations = 3; + } + + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. + google.protobuf.Timestamp index_time = 2; + + // List of results, one for each product match. + repeated Result results = 5; + + // List of results grouped by products detected in the query image. Each entry + // corresponds to one bounding polygon in the query image, and contains the + // matching products specific to that region. There may be duplicate product + // matches in the union of all the per-product results. + repeated GroupedResult product_grouped_results = 6; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto new file mode 100644 index 00000000..df7bc7a3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto @@ -0,0 +1,1039 @@ +// 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.vision.v1p4beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/vision/v1p4beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "ProductSearchServiceProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Manages Products and ProductSets of reference images for use in product +// search. It uses the following resource model: +// +// - The API has a collection of +// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named +// `projects/*/locations/*/productSets/*`, which acts as a way to put different +// products into groups to limit identification. +// +// In parallel, +// +// - The API has a collection of +// [Product][google.cloud.vision.v1p4beta1.Product] resources, named +// `projects/*/locations/*/products/*` +// +// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of +// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, +// named +// `projects/*/locations/*/products/*/referenceImages/*` +service ProductSearch { + option (google.api.default_host) = "vision.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-vision"; + + // Creates and returns a new ProductSet resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + // 4096 characters. + rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + body: "product_set" + }; + option (google.api.method_signature) = "parent,product_set,product_set_id"; + } + + // Lists ProductSets in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + // than 1. + rpc ListProductSets(ListProductSetsRequest) + returns (ListProductSetsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ProductSet. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a ProductSet resource. + // Only display_name can be updated currently. + // + // Possible errors: + // + // * Returns NOT_FOUND if the ProductSet does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but + // missing from the request or longer than 4096 characters. + rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { + option (google.api.http) = { + patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" + body: "product_set" + }; + option (google.api.method_signature) = "product_set,update_mask"; + } + + // Permanently deletes a ProductSet. Products and ReferenceImages in the + // ProductSet are not deleted. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteProductSet(DeleteProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new product resource. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is missing or invalid. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Lists products in an unspecified order. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a Product. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Makes changes to a Product resource. + // Only the `display_name`, `description`, and `labels` fields can be updated + // right now. + // + // If labels are updated, the change will not be reflected in queries until + // the next index time. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product does not exist. + // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + // missing from the request or longer than 4096 characters. + // * Returns INVALID_ARGUMENT if description is present in update_mask but is + // longer than 4096 characters. + // * Returns INVALID_ARGUMENT if product_category is present in update_mask. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Permanently deletes a product and its reference images. + // + // Metadata of the product and all its images will be deleted right away, but + // search queries against ProductSets containing the product may still work + // until all related caches are refreshed. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates and returns a new ReferenceImage resource. + // + // The `bounding_poly` field is optional. If `bounding_poly` is not specified, + // the system will try to detect regions of interest in the image that are + // compatible with the product_category on the parent product. If it is + // specified, detection is ALWAYS skipped. The system converts polygons into + // non-rotated rectangles. + // + // Note that the pipeline will resize the image if the image resolution is too + // large to process (above 50MP). + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + // characters. + // * Returns INVALID_ARGUMENT if the product does not exist. + // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + // compatible with the parent product's product_category is detected. + // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + rpc CreateReferenceImage(CreateReferenceImageRequest) + returns (ReferenceImage) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + body: "reference_image" + }; + option (google.api.method_signature) = + "parent,reference_image,reference_image_id"; + } + + // Permanently deletes a reference image. + // + // The image metadata will be deleted right away, but search queries + // against ProductSets containing the image may still work until all related + // caches are refreshed. + // + // The actual image files are not deleted from Google Cloud Storage. + rpc DeleteReferenceImage(DeleteReferenceImageRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists reference images. + // + // Possible errors: + // + // * Returns NOT_FOUND if the parent product does not exist. + // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + // than 1. + rpc ListReferenceImages(ListReferenceImagesRequest) + returns (ListReferenceImagesResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets information associated with a ReferenceImage. + // + // Possible errors: + // + // * Returns NOT_FOUND if the specified image does not exist. + rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Adds a Product to the specified ProductSet. If the Product is already + // present, no change is made. + // + // One Product can be added to at most 100 ProductSets. + // + // Possible errors: + // + // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + rpc AddProductToProductSet(AddProductToProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Removes a Product from the specified ProductSet. + rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" + body: "*" + }; + option (google.api.method_signature) = "name,product"; + } + + // Lists the Products in a ProductSet, in an unspecified order. If the + // ProductSet does not exist, the products field of the response will be + // empty. + // + // Possible errors: + // + // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + rpc ListProductsInProductSet(ListProductsInProductSetRequest) + returns (ListProductsInProductSetResponse) { + option (google.api.http) = { + get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" + }; + option (google.api.method_signature) = "name"; + } + + // Asynchronous API that imports a list of reference images to specified + // product sets based on a list of image information. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + // `Operation.response` contains `ImportProductSetsResponse`. (results) + // + // The input source of this method is a csv file on Google Cloud Storage. + // For the format of the csv file please see + // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. + rpc ImportProductSets(ImportProductSetsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" + body: "*" + }; + option (google.api.method_signature) = "parent,input_config"; + option (google.longrunning.operation_info) = { + response_type: "ImportProductSetsResponse" + metadata_type: "BatchOperationMetadata" + }; + } + + // Asynchronous API to delete all Products in a ProductSet or all Products + // that are in no ProductSet. + // + // If a Product is a member of the specified ProductSet in addition to other + // ProductSets, the Product will still be deleted. + // + // It is recommended to not delete the specified ProductSet until after this + // operation has completed. It is also recommended to not add any of the + // Products involved in the batch delete to a new ProductSet while this + // operation is running because those Products may still end up deleted. + // + // It's not possible to undo the PurgeProducts operation. Therefore, it is + // recommended to keep the csv files used in ImportProductSets (if that was + // how you originally built the Product Set) before starting PurgeProducts, in + // case you need to re-import the data after deletion. + // + // If the plan is to purge all of the Products from a ProductSet and then + // re-use the empty ProductSet to re-import new Products into the empty + // ProductSet, you must wait until the PurgeProducts operation has finished + // for that ProductSet. + // + // The [google.longrunning.Operation][google.longrunning.Operation] API can be + // used to keep track of the progress and results of the request. + // `Operation.metadata` contains `BatchOperationMetadata`. (progress) + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "BatchOperationMetadata" + }; + } +} + +// A Product contains ReferenceImages. +message Product { + option (google.api.resource) = { + type: "vision.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/products/{product}" + }; + + // A product label represented as a key-value pair. + message KeyValue { + // The key of the label attached to the product. Cannot be empty and cannot + // exceed 128 bytes. + string key = 1; + + // The value of the label attached to the product. Cannot be empty and + // cannot exceed 128 bytes. + string value = 2; + } + + // The resource name of the product. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + // + // This field is ignored when creating a product. + string name = 1; + + // The user-provided name for this Product. Must not be empty. Must be at most + // 4096 characters long. + string display_name = 2; + + // User-provided metadata to be stored with this product. Must be at most 4096 + // characters long. + string description = 3; + + // Immutable. The category for the product identified by the reference image. + // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The + // legacy categories "homegoods", "apparel", and "toys" are still supported, + // but these should not be used for new products. + string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; + + // Key-value pairs that can be attached to a product. At query time, + // constraints can be specified based on the product_labels. + // + // Note that integer values can be provided as strings, e.g. "1199". Only + // strings with integer values can match a range-based restriction which is + // to be supported soon. + // + // Multiple values can be assigned to the same key. One product may have up to + // 500 product_labels. + // + // Notice that the total number of distinct product_labels over all products + // in one ProductSet cannot exceed 1M, otherwise the product search pipeline + // will refuse to work for that ProductSet. + repeated KeyValue product_labels = 5; +} + +// A ProductSet contains Products. A ProductSet can contain a maximum of 1 +// million reference images. If the limit is exceeded, periodic indexing will +// fail. +message ProductSet { + option (google.api.resource) = { + type: "vision.googleapis.com/ProductSet" + pattern: "projects/{project}/locations/{location}/productSets/{product_set}" + }; + + // The resource name of the ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. + // + // This field is ignored when creating a ProductSet. + string name = 1; + + // The user-provided name for this ProductSet. Must not be empty. Must be at + // most 4096 characters long. + string display_name = 2; + + // Output only. The time at which this ProductSet was last indexed. Query + // results will reflect all updates before this time. If this ProductSet has + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". + // + // This field is ignored when creating a ProductSet. + google.protobuf.Timestamp index_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If there was an error with indexing the product set, the field + // is populated. + // + // This field is ignored when creating a ProductSet. + google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A `ReferenceImage` represents a product image and its associated metadata, +// such as bounding boxes. +message ReferenceImage { + option (google.api.resource) = { + type: "vision.googleapis.com/ReferenceImage" + pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" + }; + + // The resource name of the reference image. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + // + // This field is ignored when creating a reference image. + string name = 1; + + // Required. The Google Cloud Storage URI of the reference image. + // + // The URI must start with `gs://`. + string uri = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Bounding polygons around the areas of interest in the reference + // image. If this field is empty, the system will try to detect regions of + // interest. At most 10 bounding polygons will be used. + // + // The provided shape is converted into a non-rotated rectangle. Once + // converted, the small edge of the rectangle must be greater than or equal + // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 + // is not). + repeated BoundingPoly bounding_polys = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request message for the `CreateProduct` method. +message CreateProductRequest { + // Required. The project in which the Product should be created. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The product to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this Product. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_id = 3; +} + +// Request message for the `ListProducts` method. +message ListProductsRequest { + // Required. The project OR ProductSet from which Products should be listed. + // + // Format: + // `projects/PROJECT_ID/locations/LOC_ID` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProducts` method. +message ListProductsResponse { + // List of products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProduct` method. +message GetProductRequest { + // Required. Resource name of the Product to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `UpdateProduct` method. +message UpdateProductRequest { + // Required. The Product resource which replaces the one on the server. + // product.name is immutable. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields + // to update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask paths include `product_labels`, `display_name`, and + // `description`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProduct` method. +message DeleteProductRequest { + // Required. Resource name of product to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `CreateProductSet` method. +message CreateProductSetRequest { + // Required. The project in which the ProductSet should be created. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The ProductSet to create. + ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for this ProductSet. If set, the server will + // attempt to use this value as the resource id. If it is already in use, an + // error is returned with code ALREADY_EXISTS. Must be at most 128 characters + // long. It cannot contain the character `/`. + string product_set_id = 3; +} + +// Request message for the `ListProductSets` method. +message ListProductSetsRequest { + // Required. The project from which ProductSets should be listed. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductSets` method. +message ListProductSetsResponse { + // List of ProductSets. + repeated ProductSet product_sets = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// Request message for the `GetProductSet` method. +message GetProductSetRequest { + // Required. Resource name of the ProductSet to get. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `UpdateProductSet` method. +message UpdateProductSetRequest { + // Required. The ProductSet resource which replaces the one on the server. + ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to + // update. + // If update_mask isn't specified, all mutable fields are to be updated. + // Valid mask path is `display_name`. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the `DeleteProductSet` method. +message DeleteProductSetRequest { + // Required. Resource name of the ProductSet to delete. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; +} + +// Request message for the `CreateReferenceImage` method. +message CreateReferenceImageRequest { + // Required. Resource name of the product in which to create the reference + // image. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // Required. The reference image to create. + // If an image ID is specified, it is ignored. + ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; + + // A user-supplied resource id for the ReferenceImage to be added. If set, + // the server will attempt to use this value as the resource id. If it is + // already in use, an error is returned with code ALREADY_EXISTS. Must be at + // most 128 characters long. It cannot contain the character `/`. + string reference_image_id = 3; +} + +// Request message for the `ListReferenceImages` method. +message ListReferenceImagesRequest { + // Required. Resource name of the product containing the reference images. + // + // Format is + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This is the value + // of `nextPageToken` returned in a previous reference image list request. + // + // Defaults to the first page if not specified. + string page_token = 3; +} + +// Response message for the `ListReferenceImages` method. +message ListReferenceImagesResponse { + // The list of reference images. + repeated ReferenceImage reference_images = 1; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string next_page_token = 3; +} + +// Request message for the `GetReferenceImage` method. +message GetReferenceImageRequest { + // Required. The resource name of the ReferenceImage to get. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `DeleteReferenceImage` method. +message DeleteReferenceImageRequest { + // Required. The resource name of the reference image to delete. + // + // Format is: + // + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ReferenceImage" + } + ]; +} + +// Request message for the `AddProductToProductSet` method. +message AddProductToProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be added to this ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `RemoveProductFromProductSet` method. +message RemoveProductFromProductSetRequest { + // Required. The resource name for the ProductSet to modify. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // Required. The resource name for the Product to be removed from this + // ProductSet. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + string product = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } + ]; +} + +// Request message for the `ListProductsInProductSet` method. +message ListProductsInProductSetRequest { + // Required. The ProductSet resource for which to retrieve Products. + // + // Format is: + // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "vision.googleapis.com/ProductSet" + } + ]; + + // The maximum number of items to return. Default 10, maximum 100. + int32 page_size = 2; + + // The next_page_token returned from a previous List request, if any. + string page_token = 3; +} + +// Response message for the `ListProductsInProductSet` method. +message ListProductsInProductSetResponse { + // The list of Products. + repeated Product products = 1; + + // Token to retrieve the next page of results, or empty if there are no more + // results in the list. + string next_page_token = 2; +} + +// The Google Cloud Storage location for a csv file which preserves a list of +// ImportProductSetRequests in each line. +message ImportProductSetsGcsSource { + // The Google Cloud Storage URI of the input csv file. + // + // The URI must start with `gs://`. + // + // The format of the input csv file should be one image per line. + // In each line, there are 8 columns. + // + // 1. image-uri + // 2. image-id + // 3. product-set-id + // 4. product-id + // 5. product-category + // 6. product-display-name + // 7. labels + // 8. bounding-poly + // + // The `image-uri`, `product-set-id`, `product-id`, and `product-category` + // columns are required. All other columns are optional. + // + // If the `ProductSet` or `Product` specified by the `product-set-id` and + // `product-id` values does not exist, then the system will create a new + // `ProductSet` or `Product` for the image. In this case, the + // `product-display-name` column refers to + // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the + // `product-category` column refers to + // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], + // and the `labels` column refers to + // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. + // + // The `image-id` column is optional but must be unique if provided. If it is + // empty, the system will automatically assign a unique id to the image. + // + // The `product-display-name` column is optional. If it is empty, the system + // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] + // field for the product to a space (" "). You can update the `display_name` + // later by using the API. + // + // If a `Product` with the specified `product-id` already exists, then the + // system ignores the `product-display-name`, `product-category`, and `labels` + // columns. + // + // The `labels` column (optional) is a line containing a list of + // comma-separated key-value pairs, in the following format: + // + // "key_1=value_1,key_2=value_2,...,key_n=value_n" + // + // The `bounding-poly` column (optional) identifies one region of + // interest from the image in the same manner as `CreateReferenceImage`. If + // you do not specify the `bounding-poly` column, then the system will try to + // detect regions of interest automatically. + // + // At most one `bounding-poly` column is allowed per line. If the image + // contains multiple regions of interest, add a line to the CSV file that + // includes the same product information, and the `bounding-poly` values for + // each region of interest. + // + // The `bounding-poly` column must contain an even number of comma-separated + // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use + // non-negative integers for absolute bounding polygons, and float values + // in [0, 1] for normalized bounding polygons. + // + // The system will resize the image if the image resolution is too + // large to process (larger than 20MP). + string csv_file_uri = 1; +} + +// The input content for the `ImportProductSets` method. +message ImportProductSetsInputConfig { + // The source of the input. + oneof source { + // The Google Cloud Storage location for a csv file which preserves a list + // of ImportProductSetRequests in each line. + ImportProductSetsGcsSource gcs_source = 1; + } +} + +// Request message for the `ImportProductSets` method. +message ImportProductSetsRequest { + // Required. The project in which the ProductSets should be imported. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The input content for the list of requests. + ImportProductSetsInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the `ImportProductSets` method. +// +// This message is returned by the +// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] +// method in the returned +// [google.longrunning.Operation.response][google.longrunning.Operation.response] +// field. +message ImportProductSetsResponse { + // The list of reference_images that are imported successfully. + repeated ReferenceImage reference_images = 1; + + // The rpc status for each ImportProductSet request, including both successes + // and errors. + // + // The number of statuses here matches the number of lines in the csv file, + // and statuses[i] stores the success or failure status of processing the i-th + // line of the csv, starting from line 0. + repeated google.rpc.Status statuses = 2; +} + +// Metadata for the batch operations such as the current state. +// +// This is included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message BatchOperationMetadata { + // Enumerates the possible states that the batch request can be in. + enum State { + // Invalid. + STATE_UNSPECIFIED = 0; + + // Request is actively being processed. + PROCESSING = 1; + + // The request is done and at least one item has been successfully + // processed. + SUCCESSFUL = 2; + + // The request is done and no item has been successfully processed. + FAILED = 3; + + // The request is done after the longrunning.Operations.CancelOperation has + // been called by the user. Any records that were processed before the + // cancel command are output as specified in the request. + CANCELLED = 4; + } + + // The current state of the batch operation. + State state = 1; + + // The time when the batch request was submitted to the server. + google.protobuf.Timestamp submit_time = 2; + + // The time when the batch request is finished and + // [google.longrunning.Operation.done][google.longrunning.Operation.done] is + // set to true. + google.protobuf.Timestamp end_time = 3; +} + +// Config to control which ProductSet contains the Products to be deleted. +message ProductSetPurgeConfig { + // The ProductSet that contains the Products to delete. If a Product is a + // member of product_set_id in addition to other ProductSets, the Product will + // still be deleted. + string product_set_id = 1; +} + +// Request message for the `PurgeProducts` method. +message PurgeProductsRequest { + // The Products to delete. + oneof target { + // Specify which ProductSet contains the Products to be deleted. + ProductSetPurgeConfig product_set_purge_config = 2; + + // If delete_orphan_products is true, all Products that are not in any + // ProductSet will be deleted. + bool delete_orphan_products = 3; + } + + // Required. The project and location in which the Products should be deleted. + // + // Format is `projects/PROJECT_ID/locations/LOC_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The default value is false. Override this value to true to actually perform + // the purge. + bool force = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto new file mode 100644 index 00000000..233c4c68 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto @@ -0,0 +1,260 @@ +// 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.vision.v1p4beta1; + +import "google/cloud/vision/v1p4beta1/geometry.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "TextAnnotationProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// TextAnnotation contains a structured representation of OCR extracted text. +// The hierarchy of an OCR extracted text structure is like this: +// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol +// Each structural component, starting from Page, may further have their own +// properties. Properties describe detected languages, breaks etc.. Please refer +// to the +// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] +// message definition below for more detail. +message TextAnnotation { + // 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; + } + + // Detected start or end of a structural component. + message DetectedBreak { + // Enum to denote the type of break found. New line, space etc. + enum BreakType { + // Unknown break label type. + UNKNOWN = 0; + + // Regular space. + SPACE = 1; + + // Sure space (very wide). + SURE_SPACE = 2; + + // Line-wrapping break. + EOL_SURE_SPACE = 3; + + // End-line hyphen that is not present in text; does not co-occur with + // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. + HYPHEN = 4; + + // Line break that ends a paragraph. + LINE_BREAK = 5; + } + + // Detected break type. + BreakType type = 1; + + // True if break prepends the element. + bool is_prefix = 2; + } + + // Additional information detected on the structural component. + message TextProperty { + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 1; + + // Detected start or end of a text segment. + DetectedBreak detected_break = 2; + } + + // List of pages detected by OCR. + repeated Page pages = 1; + + // UTF-8 text detected on the pages. + string text = 2; +} + +// Detected page from OCR. +message Page { + // Additional information detected on the page. + TextAnnotation.TextProperty property = 1; + + // Page width. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 width = 2; + + // Page height. For PDFs the unit is points. For images (including + // TIFFs) the unit is pixels. + int32 height = 3; + + // List of blocks of text, images etc on this page. + repeated Block blocks = 4; + + // Confidence of the OCR results on the page. Range [0, 1]. + float confidence = 5; +} + +// Logical element on the page. +message Block { + // Type of a block (text, image etc) as identified by OCR. + enum BlockType { + // Unknown block type. + UNKNOWN = 0; + + // Regular text block. + TEXT = 1; + + // Table block. + TABLE = 2; + + // Image block. + PICTURE = 3; + + // Horizontal/vertical line box. + RULER = 4; + + // Barcode block. + BARCODE = 5; + } + + // Additional information detected for the block. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the block. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // + // * when the text is horizontal it might look like: + // + // 0----1 + // | | + // 3----2 + // + // * when it's rotated 180 degrees around the top-left corner it becomes: + // + // 2----3 + // | | + // 1----0 + // + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of paragraphs in this block (if this blocks is of type text). + repeated Paragraph paragraphs = 3; + + // Detected block type (text, image etc) for this block. + BlockType block_type = 4; + + // Confidence of the OCR results on the block. Range [0, 1]. + float confidence = 5; +} + +// Structural unit of text representing a number of words in certain order. +message Paragraph { + // Additional information detected for the paragraph. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the paragraph. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of all words in this paragraph. + repeated Word words = 3; + + // Confidence of the OCR results for the paragraph. Range [0, 1]. + float confidence = 4; +} + +// A word representation. +message Word { + // Additional information detected for the word. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the word. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // List of symbols in the word. + // The order of the symbols follows the natural reading order. + repeated Symbol symbols = 3; + + // Confidence of the OCR results for the word. Range [0, 1]. + float confidence = 4; +} + +// A single symbol representation. +message Symbol { + // Additional information detected for the symbol. + TextAnnotation.TextProperty property = 1; + + // The bounding box for the symbol. + // The vertices are in the order of top-left, top-right, bottom-right, + // bottom-left. When a rotation of the bounding box is detected the rotation + // is represented as around the top-left corner as defined when the text is + // read in the 'natural' orientation. + // For example: + // * when the text is horizontal it might look like: + // 0----1 + // | | + // 3----2 + // * when it's rotated 180 degrees around the top-left corner it becomes: + // 2----3 + // | | + // 1----0 + // and the vertex order will still be (0, 1, 2, 3). + BoundingPoly bounding_box = 2; + + // The actual UTF-8 representation of the symbol. + string text = 3; + + // Confidence of the OCR results for the symbol. Range [0, 1]. + float confidence = 4; +} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto new file mode 100644 index 00000000..7d716570 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto @@ -0,0 +1,106 @@ +// 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.vision.v1p4beta1; + + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; +option java_multiple_files = true; +option java_outer_classname = "WebDetectionProto"; +option java_package = "com.google.cloud.vision.v1p4beta1"; +option objc_class_prefix = "GCVN"; + +// Relevant information for the image from the Internet. +message WebDetection { + // Entity deduced from similar images on the Internet. + message WebEntity { + // Opaque entity ID. + string entity_id = 1; + + // Overall relevancy score for the entity. + // Not normalized and not comparable across different image queries. + float score = 2; + + // Canonical description of the entity, in English. + string description = 3; + } + + // Metadata for online images. + message WebImage { + // The result image URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the image. + float score = 2; + } + + // Metadata for web pages. + message WebPage { + // The result web page URL. + string url = 1; + + // (Deprecated) Overall relevancy score for the web page. + float score = 2; + + // Title for the web page, may contain HTML markups. + string page_title = 3; + + // Fully matching images on the page. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 4; + + // Partial matching images on the page. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its + // crops. + repeated WebImage partial_matching_images = 5; + } + + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + + // Deduced entities from similar images on the Internet. + repeated WebEntity web_entities = 1; + + // Fully matching images from the Internet. + // Can include resized copies of the query image. + repeated WebImage full_matching_images = 2; + + // Partial matching images from the Internet. + // Those images are similar enough to share some key-point features. For + // example an original image will likely have partial matching for its crops. + repeated WebImage partial_matching_images = 3; + + // Web pages containing the matching images from the Internet. + repeated WebPage pages_with_matching_images = 4; + + // The visually similar image results. + repeated WebImage visually_similar_images = 6; + + // The service's best guess as to the topic of the request image. + // Inferred from similar images on the open web. + repeated WebLabel best_guess_labels = 8; +} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js new file mode 100644 index 00000000..199be36a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 async file annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js new file mode 100644 index 00000000..8cb5197f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests, outputConfig) { + // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + /** + * Required. The desired output location and metadata (e.g. format). + */ + // const outputConfig = {} + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callAsyncBatchAnnotateImages() { + // Construct request + const request = { + requests, + outputConfig, + }; + + // Run request + const [operation] = await visionClient.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAsyncBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js new file mode 100644 index 00000000..2fe101f3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateFiles() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateFiles(request); + console.log(response); + } + + callBatchAnnotateFiles(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js new file mode 100644 index 00000000..f6aaa34e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { + // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 image annotation requests for this batch. + */ + // const requests = 1234 + + // Imports the Vision library + const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ImageAnnotatorClient(); + + async function callBatchAnnotateImages() { + // Construct request + const request = { + requests, + }; + + // Run request + const response = await visionClient.batchAnnotateImages(request); + console.log(response); + } + + callBatchAnnotateImages(); + // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js new file mode 100644 index 00000000..c6ef04f0 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be added to this ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callAddProductToProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.addProductToProductSet(request); + console.log(response); + } + + callAddProductToProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js new file mode 100644 index 00000000..60ec6540 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project in which the Product should be created. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The product to create. + */ + // const product = {} + /** + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + }; + + // Run request + const response = await visionClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js new file mode 100644 index 00000000..ea4c348b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSet should be created. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The ProductSet to create. + */ + // const productSet = {} + /** + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + */ + // const productSetId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateProductSet() { + // Construct request + const request = { + parent, + productSet, + }; + + // Run request + const response = await visionClient.createProductSet(request); + console.log(response); + } + + callCreateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js new file mode 100644 index 00000000..bb6709c3 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, referenceImage) { + // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product in which to create the reference + * image. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + */ + // const referenceImage = {} + /** + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + */ + // const referenceImageId = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callCreateReferenceImage() { + // Construct request + const request = { + parent, + referenceImage, + }; + + // Run request + const response = await visionClient.createReferenceImage(request); + console.log(response); + } + + callCreateReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js new file mode 100644 index 00000000..63f362dc --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of product to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js new file mode 100644 index 00000000..72ac7fec --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteProductSet(request); + console.log(response); + } + + callDeleteProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js new file mode 100644 index 00000000..92f9f39c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 reference image to delete. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callDeleteReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.deleteReferenceImage(request); + console.log(response); + } + + callDeleteReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js new file mode 100644 index 00000000..80db0f5a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the Product to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js new file mode 100644 index 00000000..acba73c5 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the ProductSet to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getProductSet(request); + console.log(response); + } + + callGetProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js new file mode 100644 index 00000000..5dc13d64 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ReferenceImage to get. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + */ + // const name = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callGetReferenceImage() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await visionClient.getReferenceImage(request); + console.log(response); + } + + callGetReferenceImage(); + // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js new file mode 100644 index 00000000..3a422698 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { + // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 in which the ProductSets should be imported. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * Required. The input content for the list of requests. + */ + // const inputConfig = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callImportProductSets() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await visionClient.importProductSets(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js new file mode 100644 index 00000000..81e409fa --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 from which ProductSets should be listed. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductSets(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js new file mode 100644 index 00000000..8b67070e --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project OR ProductSet from which Products should be listed. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js new file mode 100644 index 00000000..869b118f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource for which to retrieve Products. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * The next_page_token returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListProductsInProductSet() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await visionClient.listProductsInProductSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProductsInProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js new file mode 100644 index 00000000..637c1f8a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the product containing the reference images. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. Default 10, maximum 100. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * Defaults to the first page if not specified. + */ + // const pageToken = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callListReferenceImages() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await visionClient.listReferenceImagesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListReferenceImages(); + // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js new file mode 100644 index 00000000..5dd66449 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Specify which ProductSet contains the Products to be deleted. + */ + // const productSetPurgeConfig = {} + /** + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + */ + // const deleteOrphanProducts = true + /** + * Required. The project and location in which the Products should be deleted. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + */ + // const parent = 'abc123' + /** + * The default value is false. Override this value to true to actually perform + * the purge. + */ + // const force = true + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await visionClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js new file mode 100644 index 00000000..af9e9c14 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, product) { + // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 for the ProductSet to modify. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + */ + // const name = 'abc123' + /** + * Required. The resource name for the Product to be removed from this + * ProductSet. + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + */ + // const product = 'abc123' + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callRemoveProductFromProductSet() { + // Construct request + const request = { + name, + product, + }; + + // Run request + const response = await visionClient.removeProductFromProductSet(request); + console.log(response); + } + + callRemoveProductFromProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js new file mode 100644 index 00000000..3c8d60bb --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + */ + // const product = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await visionClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js new file mode 100644 index 00000000..6ceb8322 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(productSet) { + // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 ProductSet resource which replaces the one on the server. + */ + // const productSet = {} + /** + * The FieldMask google.protobuf.FieldMask that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_name`. + */ + // const updateMask = {} + + // Imports the Vision library + const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; + + // Instantiates a client + const visionClient = new ProductSearchClient(); + + async function callUpdateProductSet() { + // Construct request + const request = { + productSet, + }; + + // Run request + const response = await visionClient.updateProductSet(request); + console.log(response); + } + + callUpdateProductSet(); + // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json new file mode 100644 index 00000000..65c6af72 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json @@ -0,0 +1,1027 @@ +{ + "clientLibrary": { + "name": "nodejs-vision", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.vision.v1p4beta1", + "version": "v1p4beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", + "title": "vision batchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run image detection and annotation for a batch of images.", + "canonical": true, + "file": "image_annotator.batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", + "title": "vision batchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", + "canonical": true, + "file": "image_annotator.batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "BatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", + "title": "vision asyncBatchAnnotateImages Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", + "canonical": true, + "file": "image_annotator.async_batch_annotate_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.vision.v1p4beta1.OutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateImages", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", + "title": "vision asyncBatchAnnotateFiles Sample", + "origin": "API_DEFINITION", + "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", + "canonical": true, + "file": "image_annotator.async_batch_annotate_files.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ImageAnnotatorClient", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" + }, + "method": { + "shortName": "AsyncBatchAnnotateFiles", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", + "service": { + "shortName": "ImageAnnotator", + "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", + "title": "vision createProductSet Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", + "canonical": true, + "file": "product_search.create_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "product_set_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", + "title": "vision listProductSets Sample", + "origin": "API_DEFINITION", + "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", + "title": "vision getProductSet Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", + "canonical": true, + "file": "product_search.get_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", + "title": "vision updateProductSet Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", + "canonical": true, + "file": "product_search.update_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "async": true, + "parameters": [ + { + "name": "product_set", + "type": ".google.cloud.vision.v1p4beta1.ProductSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", + "title": "vision deleteProductSet Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", + "title": "vision createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", + "canonical": true, + "file": "product_search.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", + "title": "vision listProducts Sample", + "origin": "API_DEFINITION", + "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", + "title": "vision getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", + "canonical": true, + "file": "product_search.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", + "title": "vision updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", + "canonical": true, + "file": "product_search.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.vision.v1p4beta1.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.Product", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", + "title": "vision deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", + "canonical": true, + "file": "product_search.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", + "title": "vision createReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", + "canonical": true, + "file": "product_search.create_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "reference_image", + "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" + }, + { + "name": "reference_image_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "CreateReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", + "title": "vision deleteReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", + "canonical": true, + "file": "product_search.delete_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "DeleteReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", + "title": "vision listReferenceImages Sample", + "origin": "API_DEFINITION", + "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", + "canonical": true, + "file": "product_search.list_reference_images.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListReferenceImages", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", + "title": "vision getReferenceImage Sample", + "origin": "API_DEFINITION", + "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", + "canonical": true, + "file": "product_search.get_reference_image.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "GetReferenceImage", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", + "title": "vision addProductToProductSet Sample", + "origin": "API_DEFINITION", + "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", + "canonical": true, + "file": "product_search.add_product_to_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "AddProductToProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", + "title": "vision removeProductFromProductSet Sample", + "origin": "API_DEFINITION", + "description": " Removes a Product from the specified ProductSet.", + "canonical": true, + "file": "product_search.remove_product_from_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "RemoveProductFromProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", + "title": "vision listProductsInProductSet Sample", + "origin": "API_DEFINITION", + "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", + "canonical": true, + "file": "product_search.list_products_in_product_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ListProductsInProductSet", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", + "title": "vision importProductSets Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", + "canonical": true, + "file": "product_search.import_product_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "ImportProductSets", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + }, + { + "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", + "title": "vision purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", + "canonical": true, + "file": "product_search.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "product_set_purge_config", + "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" + }, + { + "name": "delete_orphan_products", + "type": "TYPE_BOOL" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductSearchClient", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", + "service": { + "shortName": "ProductSearch", + "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts new file mode 100644 index 00000000..464f947a --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1p4beta1 from './v1p4beta1'; +const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; +const ProductSearchClient = v1p4beta1.ProductSearchClient; +type ProductSearchClient = v1p4beta1.ProductSearchClient; +export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json new file mode 100644 index 00000000..8338e641 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json @@ -0,0 +1,283 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.vision.v1p4beta1", + "libraryPackage": "@google-cloud/vision", + "services": { + "ImageAnnotator": { + "clients": { + "grpc": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ImageAnnotatorClient", + "rpcs": { + "BatchAnnotateImages": { + "methods": [ + "batchAnnotateImages" + ] + }, + "BatchAnnotateFiles": { + "methods": [ + "batchAnnotateFiles" + ] + }, + "AsyncBatchAnnotateImages": { + "methods": [ + "asyncBatchAnnotateImages" + ] + }, + "AsyncBatchAnnotateFiles": { + "methods": [ + "asyncBatchAnnotateFiles" + ] + } + } + } + } + }, + "ProductSearch": { + "clients": { + "grpc": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductSearchClient", + "rpcs": { + "CreateProductSet": { + "methods": [ + "createProductSet" + ] + }, + "GetProductSet": { + "methods": [ + "getProductSet" + ] + }, + "UpdateProductSet": { + "methods": [ + "updateProductSet" + ] + }, + "DeleteProductSet": { + "methods": [ + "deleteProductSet" + ] + }, + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "CreateReferenceImage": { + "methods": [ + "createReferenceImage" + ] + }, + "DeleteReferenceImage": { + "methods": [ + "deleteReferenceImage" + ] + }, + "GetReferenceImage": { + "methods": [ + "getReferenceImage" + ] + }, + "AddProductToProductSet": { + "methods": [ + "addProductToProductSet" + ] + }, + "RemoveProductFromProductSet": { + "methods": [ + "removeProductFromProductSet" + ] + }, + "ImportProductSets": { + "methods": [ + "importProductSets" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ListProductSets": { + "methods": [ + "listProductSets", + "listProductSetsStream", + "listProductSetsAsync" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + }, + "ListReferenceImages": { + "methods": [ + "listReferenceImages", + "listReferenceImagesStream", + "listReferenceImagesAsync" + ] + }, + "ListProductsInProductSet": { + "methods": [ + "listProductsInProductSet", + "listProductsInProductSetStream", + "listProductsInProductSetAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts new file mode 100644 index 00000000..cb620c40 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts @@ -0,0 +1,848 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/v1p4beta1/image_annotator_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './image_annotator_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. + * @class + * @memberof v1p4beta1 + */ +export class ImageAnnotatorClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + imageAnnotatorStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ImageAnnotatorClient. + * + * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; + const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), + asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), + asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), + asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { + return this.imageAnnotatorStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ImageAnnotator. + this.imageAnnotatorStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, + 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 imageAnnotatorStubMethods = + ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; + for (const methodName of imageAnnotatorStubMethods) { + const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + 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 -- + // ------------------- +/** + * Run image detection and annotation for a batch of images. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async + */ + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateImages(request, options, callback); + } +/** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. The list of file annotation requests. Right now we support only + * one AnnotateFileRequest in BatchAnnotateFilesRequest. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. + * 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/v1p4beta1/image_annotator.batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async + */ + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): void; + batchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, + protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.batchAnnotateFiles(request, options, callback); + } + +/** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual image annotation requests for this batch. + * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateImages( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async + */ + async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual async file annotation requests for this batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + asyncBatchAnnotateFiles( + request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); + } +/** + * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. + * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js + * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async + */ + async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.imageAnnotatorStub && !this._terminated) { + return this.imageAnnotatorStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json new file mode 100644 index 00000000..e068ba98 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ImageAnnotator": { + "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": { + "BatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "BatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateFiles": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts new file mode 100644 index 00000000..549f810f --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient} from './image_annotator_client'; +export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts new file mode 100644 index 00000000..d7092156 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts @@ -0,0 +1,2661 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p4beta1/product_search_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_search_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named + * `projects/* /locations/* /productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of + * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named + * `projects/* /locations/* /products/*` + * + * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of + * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, + * named + * `projects/* /locations/* /products/* /referenceImages/*` + * @class + * @memberof v1p4beta1 + */ +export class ProductSearchClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productSearchStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductSearchClient. + * + * @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 ProductSearchClient({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 ProductSearchClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}' + ), + productSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/productSets/{product_set}' + ), + referenceImagePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' + ), + }; + + // 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 = { + listProductSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), + listProducts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), + listReferenceImages: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), + listProductsInProductSet: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importProductSetsResponse = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; + const importProductSetsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProductSets: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductSetsResponse.decode.bind(importProductSetsResponse), + importProductSetsMetadata.decode.bind(importProductSetsMetadata)), + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { + return this.productSearchStub; + } + + // Put together the "service stub" for + // google.cloud.vision.v1p4beta1.ProductSearch. + this.productSearchStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, + 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 productSearchStubMethods = + ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; + for (const methodName of productSearchStubMethods) { + const callPromise = this.productSearchStub.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.productSearchStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'vision.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 'vision.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', + 'https://www.googleapis.com/auth/cloud-vision' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSet should be created. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet to create. + * @param {string} request.productSetId + * A user-supplied resource id for this ProductSet. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.create_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async + */ + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): void; + createProductSet( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createProductSet(request, options, callback); + } +/** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.get_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async + */ + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): void; + getProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getProductSet(request, options, callback); + } +/** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet + * Required. The ProductSet resource which replaces the one on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to + * update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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/v1p4beta1/product_search.update_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async + */ + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): void; + updateProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet, + protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product_set.name': request.productSet!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProductSet(request, options, callback); + } +/** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the ProductSet to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async + */ + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): void; + deleteProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteProductSet(request, options, callback); + } +/** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the Product should be created. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The product to create. + * @param {string} request.productId + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.create_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): void; + createProduct( + request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } +/** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the Product to get. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.get_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): void; + getProduct( + request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } +/** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.Product} request.product + * Required. The Product resource which replaces the one on the server. + * product.name is immutable. + * @param {google.protobuf.FieldMask} request.updateMask + * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.update_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): void; + updateProduct( + request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct, + protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } +/** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of product to delete. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_product.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): void; + deleteProduct( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } +/** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product in which to create the reference + * image. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage + * Required. The reference image to create. + * If an image ID is specified, it is ignored. + * @param {string} request.referenceImageId + * A user-supplied resource id for the ReferenceImage to be added. If set, + * the server will attempt to use this value as the resource id. If it is + * already in use, an error is returned with code ALREADY_EXISTS. Must be at + * most 128 characters long. It cannot contain the character `/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.create_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async + */ + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + createReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createReferenceImage(request, options, callback); + } +/** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the reference image to delete. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async + */ + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + deleteReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); + } +/** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ReferenceImage to get. + * + * Format is: + * + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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/v1p4beta1/product_search.get_reference_image.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async + */ + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + callback: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): void; + getReferenceImage( + request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage, + protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getReferenceImage(request, options, callback); + } +/** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be added to this ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async + */ + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): void; + addProductToProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); + } +/** + * Removes a Product from the specified ProductSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the ProductSet to modify. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {string} request.product + * Required. The resource name for the Product to be removed from this + * ProductSet. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async + */ + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): void; + removeProductFromProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); + } + +/** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project in which the ProductSets should be imported. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig + * Required. The input content for the list of requests. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, + 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.importProductSets(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importProductSets()`. + * @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/v1p4beta1/product_search.import_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async + */ + async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be + * used to keep track of the progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig + * Specify which ProductSet contains the Products to be deleted. + * @param {boolean} request.deleteOrphanProducts + * If delete_orphan_products is true, all Products that are not in any + * ProductSet will be deleted. + * @param {string} request.parent + * Required. The project and location in which the Products should be deleted. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {boolean} request.force + * The default value is false. Override this value to true to actually perform + * the purge. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeProducts( + request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, + 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.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.purge_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async + */ + async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. + * 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 `listProductSetsAsync()` + * 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. + */ + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): void; + listProductSets( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProductSet>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProductSet[], + protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` + * 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. + */ + listProductSetsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.createStream( + this.innerApiCalls.listProductSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. + * + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [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 + * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async + */ + listProductSetsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, + 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['listProductSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductSets.asyncIterate( + this.innerApiCalls['listProductSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProducts( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. + * 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; + listReferenceImages( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IReferenceImage>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IReferenceImage[], + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, + protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` + * 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. + */ + listReferenceImagesStream( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.createStream( + this.innerApiCalls.listReferenceImages as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. + * + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This is the value + * of `nextPageToken` returned in a previous reference image list request. + * + * Defaults to the first page if not specified. + * @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 + * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async + */ + listReferenceImagesAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, + 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['listReferenceImages']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listReferenceImages.asyncIterate( + this.innerApiCalls['listReferenceImages'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + callback: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): void; + listProductsInProductSet( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>, + callback?: PaginationCallback< + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, + protos.google.cloud.vision.v1p4beta1.IProduct>): + Promise<[ + protos.google.cloud.vision.v1p4beta1.IProduct[], + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, + protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listProductsInProductSet(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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsInProductSetAsync()` + * 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. + */ + listProductsInProductSetStream( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.createStream( + this.innerApiCalls.listProductsInProductSet as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProductsInProductSet`, 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.name + * Required. The ProductSet resource for which to retrieve Products. + * + * Format is: + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + * @param {number} request.pageSize + * The maximum number of items to return. Default 10, maximum 100. + * @param {string} request.pageToken + * The next_page_token returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js + * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async + */ + listProductsInProductSetAsync( + request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProductsInProductSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProductsInProductSet.asyncIterate( + this.innerApiCalls['listProductsInProductSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @returns {string} Resource name string. + */ + productPath(project:string,location:string,product:string) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified productSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product_set + * @returns {string} Resource name string. + */ + productSetPath(project:string,location:string,productSet:string) { + return this.pathTemplates.productSetPathTemplate.render({ + project: project, + location: location, + product_set: productSet, + }); + } + + /** + * Parse the project from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).project; + } + + /** + * Parse the location from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).location; + } + + /** + * Parse the product_set from ProductSet resource. + * + * @param {string} productSetName + * A fully-qualified path representing ProductSet resource. + * @returns {string} A string representing the product_set. + */ + matchProductSetFromProductSetName(productSetName: string) { + return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; + } + + /** + * Return a fully-qualified referenceImage resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} product + * @param {string} reference_image + * @returns {string} Resource name string. + */ + referenceImagePath(project:string,location:string,product:string,referenceImage:string) { + return this.pathTemplates.referenceImagePathTemplate.render({ + project: project, + location: location, + product: product, + reference_image: referenceImage, + }); + } + + /** + * Parse the project from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the project. + */ + matchProjectFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; + } + + /** + * Parse the location from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the location. + */ + matchLocationFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; + } + + /** + * Parse the product from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the product. + */ + matchProductFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; + } + + /** + * Parse the reference_image from ReferenceImage resource. + * + * @param {string} referenceImageName + * A fully-qualified path representing ReferenceImage resource. + * @returns {string} A string representing the reference_image. + */ + matchReferenceImageFromReferenceImageName(referenceImageName: string) { + return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; + } + + /** + * 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.productSearchStub && !this._terminated) { + return this.productSearchStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json new file mode 100644 index 00000000..518529b7 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json @@ -0,0 +1,120 @@ +{ + "interfaces": { + "google.cloud.vision.v1p4beta1.ProductSearch": { + "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": { + "CreateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProducts": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProduct": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProduct": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListReferenceImages": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetReferenceImage": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AddProductToProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveProductFromProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProductsInProductSet": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ImportProductSets": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PurgeProducts": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json new file mode 100644 index 00000000..04693e04 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/vision/v1p4beta1/face.proto", + "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", + "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", + "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", + "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", + "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" +] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..0a49ea13 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 vision = require('@google-cloud/vision'); + +function main() { + const imageAnnotatorClient = new vision.ImageAnnotatorClient(); + const productSearchClient = new vision.ProductSearchClient(); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..4f095534 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; + +// check that the client class type name can be used +function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { + client.close(); +} +function doStuffWithProductSearchClient(client: ProductSearchClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const imageAnnotatorClient = new ImageAnnotatorClient(); + doStuffWithImageAnnotatorClient(imageAnnotatorClient); + // check that the client instance can be created + const productSearchClient = new ProductSearchClient(); + doStuffWithProductSearchClient(productSearchClient); +} + +main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts new file mode 100644 index 00000000..e4af9d0b --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts @@ -0,0 +1,693 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 imageannotatorModule 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('v1p4beta1.ImageAnnotatorClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + await client.initialize(); + assert(client.imageAnnotatorStub); + }); + + it('has close method for the initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.imageAnnotatorStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.imageAnnotatorStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateImages(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() + ); + client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateImages with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + + it('invokes batchAnnotateImages with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateImages(request), expectedError); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); + const [response] = await client.batchAnnotateFiles(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() + ); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchAnnotateFiles( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes batchAnnotateFiles with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + + it('invokes batchAnnotateFiles with closed client', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchAnnotateFiles(request), expectedError); + }); + }); + + describe('asyncBatchAnnotateImages', () => { + it('invokes asyncBatchAnnotateImages without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateImages(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateImages without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateImages( + 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); + }); + + it('invokes asyncBatchAnnotateImages with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); + }); + + it('invokes asyncBatchAnnotateImages with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateImages(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('asyncBatchAnnotateFiles', () => { + it('invokes asyncBatchAnnotateFiles without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); + const [operation] = await client.asyncBatchAnnotateFiles(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes asyncBatchAnnotateFiles without error using callback', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asyncBatchAnnotateFiles( + 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); + }); + + it('invokes asyncBatchAnnotateFiles with call error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); + }); + + it('invokes asyncBatchAnnotateFiles with LRO error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.asyncBatchAnnotateFiles(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts new file mode 100644 index 00000000..0bdcbcb8 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts @@ -0,0 +1,3100 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 productsearchModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p4beta1.ProductSearchClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productsearchModule.v1p4beta1.ProductSearchClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + await client.initialize(); + assert(client.productSearchStub); + }); + + it('has close method for the initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productSearchStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productSearchStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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 productsearchModule.v1p4beta1.ProductSearchClient({ + 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('createProductSet', () => { + it('invokes createProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.createProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProductSet(request), expectedError); + }); + }); + + describe('getProductSet', () => { + it('invokes getProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.getProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProductSet(request), expectedError); + }); + }); + + describe('updateProductSet', () => { + it('invokes updateProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ProductSet() + ); + client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() + ); + request.productSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); + request.productSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProductSet(request), expectedError); + }); + }); + + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProductSet(request), expectedError); + }); + }); + + describe('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.createReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createReferenceImage(request), expectedError); + }); + }); + + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.deleteReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReferenceImage( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteReferenceImage(request), expectedError); + }); + }); + + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); + const [response] = await client.getReferenceImage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ReferenceImage() + ); + client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReferenceImage( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getReferenceImage(request), expectedError); + const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getReferenceImage with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getReferenceImage(request), expectedError); + }); + }); + + describe('addProductToProductSet', () => { + it('invokes addProductToProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.addProductToProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addProductToProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addProductToProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addProductToProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addProductToProductSet(request), expectedError); + }); + }); + + describe('removeProductFromProductSet', () => { + it('invokes removeProductFromProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.removeProductFromProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeProductFromProductSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeProductFromProductSet with closed client', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeProductFromProductSet(request), expectedError); + }); + }); + + describe('importProductSets', () => { + it('invokes importProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); + const [operation] = await client.importProductSets(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProductSets( + 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.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProductSets with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProductSets(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductSetsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductSetsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + 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.checkImportProductSetsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|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.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProductSets', () => { + it('invokes listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); + const [response] = await client.listProductSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductSets( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductSetsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + 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.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductSetsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), + ]; + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + const iterable = client.listProductSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductSets with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); + const [response] = await client.listReferenceImages(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReferenceImages( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listReferenceImages(request), expectedError); + const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listReferenceImagesStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + 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.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listReferenceImagesStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listReferenceImagesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), + ]; + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + const iterable = client.listReferenceImagesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listReferenceImages with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReferenceImagesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProductsInProductSet', () => { + it('invokes listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); + const [response] = await client.listProductsInProductSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet without error using callback', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProductsInProductSet( + request, + (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProductsInProductSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsInProductSetStream without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsInProductSetStream with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsInProductSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; + stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); + assert( + (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet without error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), + ]; + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + const iterable = client.listProductsInProductSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProductsInProductSet with error', async () => { + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsInProductSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('product', () => { + const fakePath = "/rendered/path/product"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath("projectValue", "locationValue", "productValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('productSet', () => { + const fakePath = "/rendered/path/productSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product_set: "productSetValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.productSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('productSetPath', () => { + const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProductSetName', () => { + const result = client.matchProjectFromProductSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProductSetName', () => { + const result = client.matchLocationFromProductSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductSetFromProductSetName', () => { + const result = client.matchProductSetFromProductSetName(fakePath); + assert.strictEqual(result, "productSetValue"); + assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('referenceImage', () => { + const fakePath = "/rendered/path/referenceImage"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + product: "productValue", + reference_image: "referenceImageValue", + }; + const client = new productsearchModule.v1p4beta1.ProductSearchClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.referenceImagePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.referenceImagePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('referenceImagePath', () => { + const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromReferenceImageName', () => { + const result = client.matchProjectFromReferenceImageName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromReferenceImageName', () => { + const result = client.matchLocationFromReferenceImageName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProductFromReferenceImageName', () => { + const result = client.matchProductFromReferenceImageName(fakePath); + assert.strictEqual(result, "productValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceImageFromReferenceImageName', () => { + const result = client.matchReferenceImageFromReferenceImageName(fakePath); + assert.strictEqual(result, "referenceImageValue"); + assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js new file mode 100644 index 00000000..ebd5134c --- /dev/null +++ b/owl-bot-staging/v1p4beta1/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: 'vision', + filename: './vision.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 196d67d0a6bd0a899d2a09f066b9764e087ad349 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 21 Sep 2022 02:07:11 +0000 Subject: [PATCH 8/9] =?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 --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 65 - .../google/cloud/vision/v1/geometry.proto | 68 - .../cloud/vision/v1/image_annotator.proto | 1044 ------ .../cloud/vision/v1/product_search.proto | 124 - .../vision/v1/product_search_service.proto | 1022 ------ .../cloud/vision/v1/text_annotation.proto | 258 -- .../cloud/vision/v1/web_detection.proto | 104 - ...ge_annotator.async_batch_annotate_files.js | 73 - ...e_annotator.async_batch_annotate_images.js | 78 - .../image_annotator.batch_annotate_files.js | 73 - .../image_annotator.batch_annotate_images.js | 72 - ...oduct_search.add_product_to_product_set.js | 70 - .../v1/product_search.create_product.js | 75 - .../v1/product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../v1/product_search.delete_product.js | 63 - .../v1/product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1/product_search.get_product.js | 63 - .../v1/product_search.get_product_set.js | 63 - .../v1/product_search.get_reference_image.js | 63 - .../v1/product_search.import_product_sets.js | 68 - .../v1/product_search.list_product_sets.js | 72 - .../v1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../v1/product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 70 - .../v1/product_search.update_product.js | 70 - .../v1/product_search.update_product_set.js | 68 - ...ippet_metadata.google.cloud.vision.v1.json | 1043 ------ owl-bot-staging/v1/src/index.ts | 27 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 283 -- .../v1/src/v1/image_annotator_client.ts | 921 ----- .../src/v1/image_annotator_client_config.json | 46 - .../v1/src/v1/image_annotator_proto_list.json | 8 - owl-bot-staging/v1/src/v1/index.ts | 20 - .../v1/src/v1/product_search_client.ts | 2654 -------------- .../src/v1/product_search_client_config.json | 121 - .../v1/src/v1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_image_annotator_v1.ts | 839 ----- .../v1/test/gapic_product_search_v1.ts | 3100 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1p1beta1/.eslintignore | 7 - owl-bot-staging/v1p1beta1/.eslintrc.json | 3 - owl-bot-staging/v1p1beta1/.gitignore | 14 - owl-bot-staging/v1p1beta1/.jsdoc.js | 55 - owl-bot-staging/v1p1beta1/.mocharc.js | 33 - owl-bot-staging/v1p1beta1/.prettierrc.js | 22 - owl-bot-staging/v1p1beta1/README.md | 1 - .../v1p1beta1/linkinator.config.json | 16 - owl-bot-staging/v1p1beta1/package.json | 64 - .../cloud/vision/v1p1beta1/geometry.proto | 53 - .../vision/v1p1beta1/image_annotator.proto | 618 ---- .../vision/v1p1beta1/text_annotation.proto | 251 -- .../vision/v1p1beta1/web_detection.proto | 103 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p1beta1.json | 55 - owl-bot-staging/v1p1beta1/src/index.ts | 25 - .../src/v1p1beta1/gapic_metadata.json | 33 - .../src/v1p1beta1/image_annotator_client.ts | 373 -- .../image_annotator_client_config.json | 31 - .../v1p1beta1/image_annotator_proto_list.json | 6 - .../v1p1beta1/src/v1p1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p1beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p1beta1.ts | 225 -- owl-bot-staging/v1p1beta1/tsconfig.json | 19 - owl-bot-staging/v1p1beta1/webpack.config.js | 64 - owl-bot-staging/v1p2beta1/.eslintignore | 7 - owl-bot-staging/v1p2beta1/.eslintrc.json | 3 - owl-bot-staging/v1p2beta1/.gitignore | 14 - owl-bot-staging/v1p2beta1/.jsdoc.js | 55 - owl-bot-staging/v1p2beta1/.mocharc.js | 33 - owl-bot-staging/v1p2beta1/.prettierrc.js | 22 - owl-bot-staging/v1p2beta1/README.md | 1 - .../v1p2beta1/linkinator.config.json | 16 - owl-bot-staging/v1p2beta1/package.json | 64 - .../cloud/vision/v1p2beta1/geometry.proto | 67 - .../vision/v1p2beta1/image_annotator.proto | 794 ----- .../vision/v1p2beta1/text_annotation.proto | 258 -- .../vision/v1p2beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...etadata.google.cloud.vision.v1p2beta1.json | 95 - owl-bot-staging/v1p2beta1/src/index.ts | 25 - .../src/v1p2beta1/gapic_metadata.json | 43 - .../src/v1p2beta1/image_annotator_client.ts | 492 --- .../image_annotator_client_config.json | 36 - .../v1p2beta1/image_annotator_proto_list.json | 6 - .../v1p2beta1/src/v1p2beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1p2beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p2beta1.ts | 355 -- owl-bot-staging/v1p2beta1/tsconfig.json | 19 - owl-bot-staging/v1p2beta1/webpack.config.js | 64 - owl-bot-staging/v1p3beta1/.eslintignore | 7 - owl-bot-staging/v1p3beta1/.eslintrc.json | 3 - owl-bot-staging/v1p3beta1/.gitignore | 14 - owl-bot-staging/v1p3beta1/.jsdoc.js | 55 - owl-bot-staging/v1p3beta1/.mocharc.js | 33 - owl-bot-staging/v1p3beta1/.prettierrc.js | 22 - owl-bot-staging/v1p3beta1/README.md | 1 - .../v1p3beta1/linkinator.config.json | 16 - owl-bot-staging/v1p3beta1/package.json | 65 - .../cloud/vision/v1p3beta1/geometry.proto | 68 - .../vision/v1p3beta1/image_annotator.proto | 833 ----- .../vision/v1p3beta1/product_search.proto | 124 - .../v1p3beta1/product_search_service.proto | 971 ------ .../vision/v1p3beta1/text_annotation.proto | 258 -- .../vision/v1p3beta1/web_detection.proto | 103 - ...ge_annotator.async_batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 76 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p3beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p3beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - ..._search.remove_product_from_product_set.js | 70 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p3beta1.json | 891 ----- owl-bot-staging/v1p3beta1/src/index.ts | 27 - .../src/v1p3beta1/gapic_metadata.json | 253 -- .../src/v1p3beta1/image_annotator_client.ts | 671 ---- .../image_annotator_client_config.json | 36 - .../v1p3beta1/image_annotator_proto_list.json | 8 - .../v1p3beta1/src/v1p3beta1/index.ts | 20 - .../src/v1p3beta1/product_search_client.ts | 2538 -------------- .../product_search_client_config.json | 116 - .../v1p3beta1/product_search_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p3beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p3beta1.ts | 504 --- .../test/gapic_product_search_v1p3beta1.ts | 2946 ---------------- owl-bot-staging/v1p3beta1/tsconfig.json | 19 - owl-bot-staging/v1p3beta1/webpack.config.js | 64 - owl-bot-staging/v1p4beta1/.eslintignore | 7 - owl-bot-staging/v1p4beta1/.eslintrc.json | 3 - owl-bot-staging/v1p4beta1/.gitignore | 14 - owl-bot-staging/v1p4beta1/.jsdoc.js | 55 - owl-bot-staging/v1p4beta1/.mocharc.js | 33 - owl-bot-staging/v1p4beta1/.prettierrc.js | 22 - owl-bot-staging/v1p4beta1/README.md | 1 - .../v1p4beta1/linkinator.config.json | 16 - owl-bot-staging/v1p4beta1/package.json | 65 - .../google/cloud/vision/v1p4beta1/face.proto | 60 - .../cloud/vision/v1p4beta1/geometry.proto | 70 - .../vision/v1p4beta1/image_annotator.proto | 967 ----- .../vision/v1p4beta1/product_search.proto | 127 - .../v1p4beta1/product_search_service.proto | 1039 ------ .../vision/v1p4beta1/text_annotation.proto | 260 -- .../vision/v1p4beta1/web_detection.proto | 106 - ...ge_annotator.async_batch_annotate_files.js | 62 - ...e_annotator.async_batch_annotate_images.js | 67 - .../image_annotator.batch_annotate_files.js | 62 - .../image_annotator.batch_annotate_images.js | 61 - ...oduct_search.add_product_to_product_set.js | 70 - .../product_search.create_product.js | 75 - .../product_search.create_product_set.js | 74 - .../product_search.create_reference_image.js | 77 - .../product_search.delete_product.js | 63 - .../product_search.delete_product_set.js | 63 - .../product_search.delete_reference_image.js | 63 - .../v1p4beta1/product_search.get_product.js | 63 - .../product_search.get_product_set.js | 63 - .../product_search.get_reference_image.js | 63 - .../product_search.import_product_sets.js | 68 - .../product_search.list_product_sets.js | 72 - .../v1p4beta1/product_search.list_products.js | 73 - ...uct_search.list_products_in_product_set.js | 73 - .../product_search.list_reference_images.js | 75 - .../product_search.purge_products.js | 77 - ..._search.remove_product_from_product_set.js | 71 - .../product_search.update_product.js | 70 - .../product_search.update_product_set.js | 68 - ...etadata.google.cloud.vision.v1p4beta1.json | 1027 ------ owl-bot-staging/v1p4beta1/src/index.ts | 27 - .../src/v1p4beta1/gapic_metadata.json | 283 -- .../src/v1p4beta1/image_annotator_client.ts | 848 ----- .../image_annotator_client_config.json | 46 - .../v1p4beta1/image_annotator_proto_list.json | 9 - .../v1p4beta1/src/v1p4beta1/index.ts | 20 - .../src/v1p4beta1/product_search_client.ts | 2661 -------------- .../product_search_client_config.json | 120 - .../v1p4beta1/product_search_proto_list.json | 9 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p4beta1/system-test/install.ts | 49 - .../test/gapic_image_annotator_v1p4beta1.ts | 693 ---- .../test/gapic_product_search_v1p4beta1.ts | 3100 ----------------- owl-bot-staging/v1p4beta1/tsconfig.json | 19 - owl-bot-staging/v1p4beta1/webpack.config.js | 64 - test/gapic_image_annotator_v1.ts | 72 +- test/gapic_product_search_v1.ts | 541 +-- test/gapic_product_search_v1p3beta1.ts | 513 +-- test/gapic_product_search_v1p4beta1.ts | 541 +-- 222 files changed, 945 insertions(+), 45135 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_image_annotator_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_product_search_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1p1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p1beta1/.gitignore delete mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p1beta1/README.md delete mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p1beta1/package.json delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json delete mode 100644 owl-bot-staging/v1p1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p2beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p2beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p2beta1/.gitignore delete mode 100644 owl-bot-staging/v1p2beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p2beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p2beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p2beta1/README.md delete mode 100644 owl-bot-staging/v1p2beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p2beta1/package.json delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json delete mode 100644 owl-bot-staging/v1p2beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p2beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts delete mode 100644 owl-bot-staging/v1p2beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p2beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p3beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p3beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p3beta1/.gitignore delete mode 100644 owl-bot-staging/v1p3beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p3beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p3beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p3beta1/README.md delete mode 100644 owl-bot-staging/v1p3beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p3beta1/package.json delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json delete mode 100644 owl-bot-staging/v1p3beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p3beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts delete mode 100644 owl-bot-staging/v1p3beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p3beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1p4beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p4beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p4beta1/.gitignore delete mode 100644 owl-bot-staging/v1p4beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p4beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p4beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p4beta1/README.md delete mode 100644 owl-bot-staging/v1p4beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p4beta1/package.json delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto delete mode 100644 owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js delete mode 100644 owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json delete mode 100644 owl-bot-staging/v1p4beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json delete mode 100644 owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p4beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts delete mode 100644 owl-bot-staging/v1p4beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p4beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/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/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/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/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/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/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1/protos/google/cloud/vision/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto deleted file mode 100644 index 7e0d24c2..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto deleted file mode 100644 index 6fed6112..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/image_annotator.proto +++ /dev/null @@ -1,1044 +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.vision.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search.proto"; -import "google/cloud/vision/v1/text_annotation.proto"; -import "google/cloud/vision/v1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1/images:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1/files:annotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:annotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:annotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/images:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/files:asyncBatchAnnotate" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate" - body: "*" - } - additional_bindings { - post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateImages requests. It does - // not work for AsyncBatchAnnotateImages requests. - bytes content = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - - // Left cheek center. - LEFT_CHEEK_CENTER = 35; - - // Right cheek center. - RIGHT_CHEEK_CENTER = 36; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only one - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 3; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no parent is specified, a region will be chosen automatically. - // - // Supported location-ids: - // `us`: USA country only, - // `asia`: East asia areas, like Japan, Taiwan, - // `eu`: The European Union. - // - // Example: `projects/project-A/locations/eu`. - string parent = 4; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto deleted file mode 100644 index a2a98505..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1/geometry.proto"; -import "google/cloud/vision/v1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto deleted file mode 100644 index 65680d90..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/product_search_service.proto +++ /dev/null @@ -1,1022 +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.vision.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/vision/v1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - // progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or - // "general-v1". The legacy categories "homegoods", "apparel", and "toys" are - // still supported, but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1.Product.product_category], and the - // `labels` column refers to [product_labels][google.cloud.vision.v1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1.Product.display_name] field for the product to a - // space (" "). You can update the `display_name` later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto deleted file mode 100644 index 9c07c322..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/text_annotation.proto +++ /dev/null @@ -1,258 +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.vision.v1; - -import "google/cloud/vision/v1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the [TextAnnotation.TextProperty][google.cloud.vision.v1.TextAnnotation.TextProperty] message definition below for more -// detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto b/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto deleted file mode 100644 index 369a1350..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/vision/v1/web_detection.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 7d7ed138..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 70be298e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 528c4d1f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_files.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 2f57a691..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/image_annotator.batch_annotate_images.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Optional. Target project and location to make a call. - * Format: `projects/{project-id}/locations/{location-id}`. - * If no parent is specified, a region will be chosen automatically. - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * Example: `projects/project-A/locations/eu`. - */ - // const parent = 'abc123' - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js deleted file mode 100644 index 1826ada2..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.js deleted file mode 100644 index 9e064a95..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product.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, product) { - // [START vision_v1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js deleted file mode 100644 index 5c580189..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js deleted file mode 100644 index 6175cef1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js deleted file mode 100644 index 8d58541b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js deleted file mode 100644 index 5c5b8125..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js deleted file mode 100644 index 18a64743..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js deleted file mode 100644 index 27e014db..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js deleted file mode 100644 index fa80ab00..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js b/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js deleted file mode 100644 index b25fb5e6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.js deleted file mode 100644 index 859e0f5a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js deleted file mode 100644 index 66a071b0..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js deleted file mode 100644 index 8fa795f6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js deleted file mode 100644 index 3e9871fc..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js b/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.js deleted file mode 100644 index f7175d39..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.list_reference_images.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 vision_v1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js b/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js deleted file mode 100644 index 0dae0b9b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js deleted file mode 100644 index ad66ef6b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js deleted file mode 100644 index d8fd49f9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js b/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js deleted file mode 100644 index 26bf5ed6..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json deleted file mode 100644 index def101a1..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.vision.v1.json +++ /dev/null @@ -1,1043 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1.OutputConfig" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 67a41d87..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /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. ** - -import * as v1 from './v1'; -const ImageAnnotatorClient = v1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1.ImageAnnotatorClient; -const ProductSearchClient = v1.ProductSearchClient; -type ProductSearchClient = v1.ProductSearchClient; -export {v1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 13fb1dac..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client.ts b/owl-bot-staging/v1/src/v1/image_annotator_client.ts deleted file mode 100644 index 3fef9c7b..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client.ts +++ /dev/null @@ -1,921 +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/v1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1.BatchAnnotateImagesResponse}. - * 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/image_annotator.batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only one - * AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. - * 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/image_annotator.batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateImagesRequest, - 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.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {string} request.parent - * Optional. Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no parent is specified, a region will be chosen automatically. - * - * Supported location-ids: - * `us`: USA country only, - * `asia`: East asia areas, like Japan, Taiwan, - * `eu`: The European Union. - * - * Example: `projects/project-A/locations/eu`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1.IAsyncBatchAnnotateFilesRequest, - 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.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json b/owl-bot-staging/v1/src/v1/image_annotator_client_config.json deleted file mode 100644 index 08f87df9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json b/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1/src/v1/product_search_client.ts b/owl-bot-staging/v1/src/v1/product_search_client.ts deleted file mode 100644 index dc96f48b..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client.ts +++ /dev/null @@ -1,2654 +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} 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/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1.Product|Product} has a collection of {@link google.cloud.vision.v1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=operations/*}',},{get: '/v1/{name=locations/*/operations/*}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.create_product_set.js - * region_tag:vision_v1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.get_product_set.js - * region_tag:vision_v1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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/product_search.update_product_set.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet, - protos.google.cloud.vision.v1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product_set.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.create_product.js - * region_tag:vision_v1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.get_product.js - * region_tag:vision_v1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.update_product.js - * region_tag:vision_v1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IProduct, - protos.google.cloud.vision.v1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_product.js - * region_tag:vision_v1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.create_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.delete_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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/product_search.get_reference_image.js - * region_tag:vision_v1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage, - protos.google.cloud.vision.v1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.add_product_to_product_set.js - * region_tag:vision_v1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/product_search.import_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/product_search.purge_products.js - * region_tag:vision_v1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductSetsRequest, - protos.google.cloud.vision.v1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1.IProductSet[], - protos.google.cloud.vision.v1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1.ProductSet}. 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/product_search.list_product_sets.js - * region_tag:vision_v1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsRequest, - protos.google.cloud.vision.v1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsRequest|null, - protos.google.cloud.vision.v1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products.js - * region_tag:vision_v1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1.IReferenceImage[], - protos.google.cloud.vision.v1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. 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/product_search.list_reference_images.js - * region_tag:vision_v1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1.IProduct[], - protos.google.cloud.vision.v1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/product_search.list_products_in_product_set.js - * region_tag:vision_v1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_client_config.json b/owl-bot-staging/v1/src/v1/product_search_client_config.json deleted file mode 100644 index b7db1b90..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_client_config.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/product_search_proto_list.json b/owl-bot-staging/v1/src/v1/product_search_proto_list.json deleted file mode 100644 index 0d468bf9..00000000 --- a/owl-bot-staging/v1/src/v1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1/geometry.proto", - "../../protos/google/cloud/vision/v1/image_annotator.proto", - "../../protos/google/cloud/vision/v1/product_search.proto", - "../../protos/google/cloud/vision/v1/product_search_service.proto", - "../../protos/google/cloud/vision/v1/text_annotation.proto", - "../../protos/google/cloud/vision/v1/web_detection.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/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/v1/test/gapic_image_annotator_v1.ts b/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts deleted file mode 100644 index 269cf78a..00000000 --- a/owl-bot-staging/v1/test/gapic_image_annotator_v1.ts +++ /dev/null @@ -1,839 +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 imageannotatorModule 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('v1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - const actualRequest = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.BatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - 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.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_product_search_v1.ts b/owl-bot-staging/v1/test/gapic_product_search_v1.ts deleted file mode 100644 index 5527a23b..00000000 --- a/owl-bot-staging/v1/test/gapic_product_search_v1.ts +++ /dev/null @@ -1,3100 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1.ProductSearchClient({ - 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 productsearchModule.v1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|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.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'vision', - filename: './vision.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/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p1beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p1beta1/.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/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json deleted file mode 100644 index a08f8678..00000000 --- a/owl-bot-staging/v1p1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto deleted file mode 100644 index 6d46d9c3..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/geometry.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// 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 bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto deleted file mode 100644 index f66ad504..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ /dev/null @@ -1,618 +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.vision.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p1beta1/geometry.proto"; -import "google/cloud/vision/v1p1beta1/text_annotation.proto"; -import "google/cloud/vision/v1p1beta1/web_detection.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p1beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } -} - -// Users describe the type of Google Cloud Vision API tasks to perform over -// images by using *Feature*s. Each Feature indicates a type of image -// detection task to perform. Features encode the Cloud Vision API -// vertical to operate on and the number of top-scoring results to return. -message Feature { - // Type of image feature. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run OCR. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run computer vision models to compute image safe-search properties. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage image location). -message ImageSource { - // NOTE: For new code `image_uri` below is preferred. - // Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - string gcs_image_uri = 1; - - // Image URI which supports: - // 1) Google Cloud Storage image URI, which must be in the following form: - // `gs://bucket_name/object_name` (for details, see - // [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris)). - // NOTE: Cloud Storage object versioning is not supported. - // 2) Publicly accessible image HTTP/HTTPS URL. - // This is preferred over the legacy `gcs_image_uri` above. When both - // `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location. If both `content` and `source` - // are provided for an image, `content` takes precedence and is - // used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // lat/long rectangle that specifies the location of the image. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto deleted file mode 100644 index f85cc44d..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/text_annotation.proto +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - -import "google/cloud/vision/v1p1beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p1beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width in pixels. - int32 width = 2; - - // Page height in pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto deleted file mode 100644 index c50e1ad6..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/vision/v1p1beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2017 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p1beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p1beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p1beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index eb0fe422..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p1beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json deleted file mode 100644 index dbece339..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.vision.v1p1beta1.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p1beta1", - "version": "v1p1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p1beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts deleted file mode 100644 index 1137dce5..00000000 --- a/owl-bot-staging/v1p1beta1/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 v1p1beta1 from './v1p1beta1'; -const ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p1beta1.ImageAnnotatorClient; -export {v1p1beta1, ImageAnnotatorClient}; -export default {v1p1beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json deleted file mode 100644 index 2dc79630..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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.vision.v1p1beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts deleted file mode 100644 index 092acab0..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client.ts +++ /dev/null @@ -1,373 +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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1p1beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p1beta1 - */ -export class ImageAnnotatorClient { - 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}; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p1beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p1beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p1beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p1beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse}. - * 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/v1p1beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p1beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json deleted file mode 100644 index 469fb95c..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p1beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json deleted file mode 100644 index 35609fc8..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p1beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p1beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p1beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p1beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p1beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p1beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts deleted file mode 100644 index cbaef061..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_image_annotator_v1p1beta1.ts +++ /dev/null @@ -1,225 +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 imageannotatorModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1p1beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p1beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p1beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p1beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p1beta1/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/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p1beta1/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: 'vision', - filename: './vision.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/v1p2beta1/.eslintignore b/owl-bot-staging/v1p2beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p2beta1/.eslintrc.json b/owl-bot-staging/v1p2beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p2beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p2beta1/.gitignore b/owl-bot-staging/v1p2beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.jsdoc.js b/owl-bot-staging/v1p2beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p2beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p2beta1/.mocharc.js b/owl-bot-staging/v1p2beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/.prettierrc.js b/owl-bot-staging/v1p2beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p2beta1/.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/v1p2beta1/README.md b/owl-bot-staging/v1p2beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p2beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p2beta1/linkinator.config.json b/owl-bot-staging/v1p2beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/package.json b/owl-bot-staging/v1p2beta1/package.json deleted file mode 100644 index a08f8678..00000000 --- a/owl-bot-staging/v1p2beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto deleted file mode 100644 index e9fec20b..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/geometry.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto deleted file mode 100644 index 264462d4..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ /dev/null @@ -1,794 +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.vision.v1p2beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p2beta1/geometry.proto"; -import "google/cloud/vision/v1p2beta1/text_annotation.proto"; -import "google/cloud/vision/v1p2beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p2beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run async image detection and annotation for a list of generic files (e.g. - // PDF) which may contain multiple pages and multiple images per page. - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p2beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file on GCS. - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a GCS - // object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto deleted file mode 100644 index af568194..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - -import "google/cloud/vision/v1p2beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p2beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto b/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto deleted file mode 100644 index 2decb859..00000000 --- a/owl-bot-staging/v1p2beta1/protos/google/cloud/vision/v1p2beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p2beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p2beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p2beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 92074c3a..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 793ec83e..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p2beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json b/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json deleted file mode 100644 index c843af75..00000000 --- a/owl-bot-staging/v1p2beta1/samples/generated/v1p2beta1/snippet_metadata.google.cloud.vision.v1p2beta1.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p2beta1", - "version": "v1p2beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run async image detection and annotation for a list of generic files (e.g. PDF) which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p2beta1.ImageAnnotator" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p2beta1/src/index.ts b/owl-bot-staging/v1p2beta1/src/index.ts deleted file mode 100644 index 0e8fea74..00000000 --- a/owl-bot-staging/v1p2beta1/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 v1p2beta1 from './v1p2beta1'; -const ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p2beta1.ImageAnnotatorClient; -export {v1p2beta1, ImageAnnotatorClient}; -export default {v1p2beta1, ImageAnnotatorClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/gapic_metadata.json deleted file mode 100644 index 116ff853..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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.vision.v1p2beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts deleted file mode 100644 index 399a91e4..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client.ts +++ /dev/null @@ -1,492 +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/v1p2beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p2beta1 - */ -export class ImageAnnotatorClient { - 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; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p2beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p2beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p2beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p2beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}. - * 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/v1p2beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run async image detection and annotation for a list of generic files (e.g. - * PDF) which may contain multiple pages and multiple images per page. - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p2beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p2beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json deleted file mode 100644 index 367627eb..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p2beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json deleted file mode 100644 index 2b5904f9..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p2beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p2beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p2beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p2beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts b/owl-bot-staging/v1p2beta1/src/v1p2beta1/index.ts deleted file mode 100644 index a9739874..00000000 --- a/owl-bot-staging/v1p2beta1/src/v1p2beta1/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 {ImageAnnotatorClient} from './image_annotator_client'; diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index cf73a1c5..00000000 --- a/owl-bot-staging/v1p2beta1/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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p2beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index bc529419..00000000 --- a/owl-bot-staging/v1p2beta1/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 {ImageAnnotatorClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); -} - -main(); diff --git a/owl-bot-staging/v1p2beta1/system-test/install.ts b/owl-bot-staging/v1p2beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts b/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts deleted file mode 100644 index 5c8ad8dc..00000000 --- a/owl-bot-staging/v1p2beta1/test/gapic_image_annotator_v1p2beta1.ts +++ /dev/null @@ -1,355 +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 imageannotatorModule 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('v1p2beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p2beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p2beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1p2beta1/tsconfig.json b/owl-bot-staging/v1p2beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p2beta1/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/v1p2beta1/webpack.config.js b/owl-bot-staging/v1p2beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p2beta1/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: 'vision', - filename: './vision.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/v1p3beta1/.eslintignore b/owl-bot-staging/v1p3beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p3beta1/.eslintrc.json b/owl-bot-staging/v1p3beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p3beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p3beta1/.gitignore b/owl-bot-staging/v1p3beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.jsdoc.js b/owl-bot-staging/v1p3beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p3beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p3beta1/.mocharc.js b/owl-bot-staging/v1p3beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/.prettierrc.js b/owl-bot-staging/v1p3beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p3beta1/.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/v1p3beta1/README.md b/owl-bot-staging/v1p3beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p3beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p3beta1/linkinator.config.json b/owl-bot-staging/v1p3beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/package.json b/owl-bot-staging/v1p3beta1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1p3beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto deleted file mode 100644 index c2c524fb..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/geometry.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto deleted file mode 100644 index ebab14a6..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ /dev/null @@ -1,833 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search.proto"; -import "google/cloud/vision/v1p3beta1/text_annotation.proto"; -import "google/cloud/vision/v1p3beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p3beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for product search. - google.cloud.vision.v1p3beta1.ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - google.cloud.vision.v1p3beta1.ProductSearchResults product_search_results = - 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. - repeated AnnotateImageResponse responses = 2; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // The type of the file. Currently only "application/pdf" and "image/tiff" - // are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. - // - // Examples: - // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto deleted file mode 100644 index 86ea1a06..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search.proto +++ /dev/null @@ -1,124 +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.vision.v1p3beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/cloud/vision/v1p3beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] to be searched for similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto deleted file mode 100644 index daf1d0dd..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/product_search_service.proto +++ /dev/null @@ -1,971 +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.vision.v1p3beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p3beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of [ProductSet][google.cloud.vision.v1p3beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of [Product][google.cloud.vision.v1p3beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p3beta1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1p3beta1.ReferenceImage] resources, named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p3beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. All Products and ReferenceImages in the - // ProductSet will be deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only display_name, description and labels can be updated right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p3beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - // - // Possible errors: - // - // * Returns NOT_FOUND if the product does not exist. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the reference image does not exist. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND If the Product is not found under the ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p3beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p3beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. This should - // be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories - // "homegoods", "apparel", and "toys" are still supported, but these should - // not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 100 product_labels. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this field is 0. - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference image. - // If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/Product" - } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 6 columns. - // 1. image_uri - // 2, image_id - // 3. product_set_id - // 4. product_id - // 5, product_category - // 6, product_display_name - // 7, labels - // 8. bounding_poly - // - // Columns 1, 3, 4, and 5 are required, other columns are optional. A new - // ProductSet/Product with the same id will be created on the fly - // if the ProductSet/Product specified by product_set_id/product_id does not - // exist. - // - // The image_id field is optional but has to be unique if provided. If it is - // empty, we will automatically assign an unique id to the image. - // - // The product_display_name field is optional. If it is empty, a space (" ") - // is used as the place holder for the product display_name, which can - // be updated later through the realtime API. - // - // If the Product with product_id already exists, the fields - // product_display_name, product_category and labels are ignored. - // - // If a Product doesn't exist and needs to be created on the fly, the - // product_display_name field refers to - // [Product.display_name][google.cloud.vision.v1p3beta1.Product.display_name], - // the product_category field refers to - // [Product.product_category][google.cloud.vision.v1p3beta1.Product.product_category], - // and the labels field refers to [Product.labels][]. - // - // Labels (optional) should be a line containing a list of comma-separated - // key-value pairs, with the format - // "key_1=value_1,key_2=value_2,...,key_n=value_n". - // - // The bounding_poly (optional) field is used to identify one region of - // interest from the image in the same manner as CreateReferenceImage. If no - // bounding_poly is specified, the system will try to detect regions of - // interest automatically. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 20MP). - // - // Also note that at most one bounding_poly is allowed per line. If the image - // contains multiple regions of interest, the csv should contain one line per - // region of interest. - // - // The bounding_poly column should contain an even number of comma-separated - // numbers, with the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Nonnegative - // integers should be used for absolute bounding polygons, and float values - // in [0, 1] should be used for normalized bounding polygons. - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto deleted file mode 100644 index 633e404e..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/text_annotation.proto +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - -import "google/cloud/vision/v1p3beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p3beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertice order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto b/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto deleted file mode 100644 index 205dfe65..00000000 --- a/owl-bot-staging/v1p3beta1/protos/google/cloud/vision/v1p3beta1/web_detection.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.vision.v1p3beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p3beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p3beta1"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // Best guess text labels for the request image. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 900c1b0b..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index 1b58eca1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Individual image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index 96b4c8ba..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.js deleted file mode 100644 index ed6ac1b8..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product.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, product) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js deleted file mode 100644 index 90879035..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js deleted file mode 100644 index 48848360..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,76 +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, referenceImage) { - // [START vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js deleted file mode 100644 index a5872042..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js deleted file mode 100644 index 7d971bc3..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js deleted file mode 100644 index c97f2727..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js deleted file mode 100644 index c62e8ea6..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js deleted file mode 100644 index 4def76dc..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js deleted file mode 100644 index 93ee9d82..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.js deleted file mode 100644 index 23698c04..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js deleted file mode 100644 index 52033c07..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js deleted file mode 100644 index 454672d1..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 65bc35e2..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.js deleted file mode 100644 index 9deb4e05..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.list_reference_images.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 vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index 45dcddaf..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js deleted file mode 100644 index 8d98838c..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js deleted file mode 100644 index cfecdb70..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p3beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json b/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json deleted file mode 100644 index 90042759..00000000 --- a/owl-bot-staging/v1p3beta1/samples/generated/v1p3beta1/snippet_metadata.google.cloud.vision.v1p3beta1.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p3beta1", - "version": "v1p3beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p3beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p3beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. All Products and ReferenceImages in the ProductSet will be deleted. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only display_name, description and labels can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p3beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed. Possible errors: * Returns NOT_FOUND if the product does not exist.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p3beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage. Possible errors: * Returns NOT_FOUND if the reference image does not exist.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet. Possible errors: * Returns NOT_FOUND If the Product is not found under the ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p3beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p3beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p3beta1/src/index.ts b/owl-bot-staging/v1p3beta1/src/index.ts deleted file mode 100644 index 9e656a03..00000000 --- a/owl-bot-staging/v1p3beta1/src/index.ts +++ /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. ** - -import * as v1p3beta1 from './v1p3beta1'; -const ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p3beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p3beta1.ProductSearchClient; -type ProductSearchClient = v1p3beta1.ProductSearchClient; -export {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p3beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json deleted file mode 100644 index 52ae14a4..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/gapic_metadata.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p3beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts deleted file mode 100644 index 2114aa92..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client.ts +++ /dev/null @@ -1,671 +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/v1p3beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p3beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse}. - * 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/v1p3beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p3beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p3beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p3beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json deleted file mode 100644 index 75a2b706..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts deleted file mode 100644 index facd3967..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client.ts +++ /dev/null @@ -1,2538 +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} 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/v1p3beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of {@link google.cloud.vision.v1p3beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p3beta1.Product|Product} has a collection of {@link google.cloud.vision.v1p3beta1.ReferenceImage|ReferenceImage} resources, named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p3beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p3beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p3beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p3beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p3beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p3beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.create_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.get_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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/v1p3beta1/product_search.update_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet, - protos.google.cloud.vision.v1p3beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. All Products and ReferenceImages in the - * ProductSet will be deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.create_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p3beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.get_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p3beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only display_name, description and labels can be updated right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p3beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.update_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct, - protos.google.cloud.vision.v1p3beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * Possible errors: - * - * * Returns NOT_FOUND if the product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_product.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p3beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.create_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the reference image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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/v1p3beta1/product_search.get_reference_image.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage, - protos.google.cloud.vision.v1p3beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND If the Product is not found under the ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p3beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p3beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p3beta1/product_search.import_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProductSet[], - protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p3beta1.ProductSet}. 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/v1p3beta1/product_search.list_product_sets.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IReferenceImage[], - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p3beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p3beta1.ReferenceImage}. 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/v1p3beta1/product_search.list_reference_images.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p3beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p3beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p3beta1.IProduct[], - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p3beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p3beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p3beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p3beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p3beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json deleted file mode 100644 index ddc1e9ad..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_client_config.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p3beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json b/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json deleted file mode 100644 index f5f413b6..00000000 --- a/owl-bot-staging/v1p3beta1/src/v1p3beta1/product_search_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p3beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p3beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p3beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p3beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p3beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p3beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p3beta1/system-test/install.ts b/owl-bot-staging/v1p3beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts deleted file mode 100644 index 7e683838..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_image_annotator_v1p3beta1.ts +++ /dev/null @@ -1,504 +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 imageannotatorModule 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('v1p3beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p3beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p3beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts b/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts deleted file mode 100644 index 970736be..00000000 --- a/owl-bot-staging/v1p3beta1/test/gapic_product_search_v1p3beta1.ts +++ /dev/null @@ -1,2946 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p3beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p3beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p3beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p3beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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 productsearchModule.v1p3beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p3beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p3beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p3beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p3beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p3beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p3beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p3beta1/tsconfig.json b/owl-bot-staging/v1p3beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p3beta1/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/v1p3beta1/webpack.config.js b/owl-bot-staging/v1p3beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p3beta1/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: 'vision', - filename: './vision.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/v1p4beta1/.eslintignore b/owl-bot-staging/v1p4beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p4beta1/.eslintrc.json b/owl-bot-staging/v1p4beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p4beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p4beta1/.gitignore b/owl-bot-staging/v1p4beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.jsdoc.js b/owl-bot-staging/v1p4beta1/.jsdoc.js deleted file mode 100644 index 3a185a84..00000000 --- a/owl-bot-staging/v1p4beta1/.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/vision', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p4beta1/.mocharc.js b/owl-bot-staging/v1p4beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/.prettierrc.js b/owl-bot-staging/v1p4beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p4beta1/.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/v1p4beta1/README.md b/owl-bot-staging/v1p4beta1/README.md deleted file mode 100644 index 083a8d0a..00000000 --- a/owl-bot-staging/v1p4beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Vision: Nodejs Client diff --git a/owl-bot-staging/v1p4beta1/linkinator.config.json b/owl-bot-staging/v1p4beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/package.json b/owl-bot-staging/v1p4beta1/package.json deleted file mode 100644 index 19f15af4..00000000 --- a/owl-bot-staging/v1p4beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/vision", - "version": "0.1.0", - "description": "Vision client for Node.js", - "repository": "googleapis/nodejs-vision", - "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 vision", - "vision", - "image annotator", - "product search" - ], - "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.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@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/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto deleted file mode 100644 index d2ab72f0..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/face.proto +++ /dev/null @@ -1,60 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "CelebrityProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a celebrity recognition request. -message FaceRecognitionParams { - // The resource names for one or more - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity - // set is preloaded and can be specified as "builtin/default". If this is - // specified, the algorithm will try to match the faces detected in the input - // image to the Celebrities in the CelebritySets. - repeated string celebrity_set = 1; -} - -// A Celebrity is a group of Faces with an identity. -message Celebrity { - // The resource name of the preloaded Celebrity. Has the format - // `builtin/{mid}`. - string name = 1; - - // The Celebrity's display name. - string display_name = 2; - - // The Celebrity's description. - string description = 3; -} - -// Information about a face's identity. -message FaceRecognitionResult { - // The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was - // matched to. - Celebrity celebrity = 1; - - // Recognition confidence. Range [0, 1]. - float confidence = 2; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto deleted file mode 100644 index 877fd897..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/geometry.proto +++ /dev/null @@ -1,70 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// 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; -} - -// A 3D position in the image, used primarily for Face detection landmarks. -// A valid Position must have both x and y coordinates. -// The position coordinates are in the same scale as the original image. -message Position { - // X coordinate. - float x = 1; - - // Y coordinate. - float y = 2; - - // Z coordinate (or depth). - float z = 3; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto deleted file mode 100644 index cc783697..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ /dev/null @@ -1,967 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/vision/v1p4beta1/face.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search.proto"; -import "google/cloud/vision/v1p4beta1/text_annotation.proto"; -import "google/cloud/vision/v1p4beta1/web_detection.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/latlng.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ImageAnnotatorProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Service that performs Google Cloud Vision API detection tasks over client -// images, such as face, landmark, logo, label, and text detection. The -// ImageAnnotator service returns detected entities from the images. -service ImageAnnotator { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Run image detection and annotation for a batch of images. - rpc BatchAnnotateImages(BatchAnnotateImagesRequest) - returns (BatchAnnotateImagesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/images:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Service that performs image detection and annotation for a batch of files. - // Now only "application/pdf", "image/tiff" and "image/gif" are supported. - // - // This service will extract at most 5 (customers can specify which 5 in - // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - // file provided and perform detection and annotation for each image - // extracted. - rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) - returns (BatchAnnotateFilesResponse) { - option (google.api.http) = { - post: "/v1p4beta1/files:annotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - } - - // Run asynchronous image detection and annotation for a list of images. - // - // Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - // - // This service will write image annotation outputs to json files in customer - // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/images:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests,output_config"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateImagesResponse" - metadata_type: "OperationMetadata" - }; - } - - // Run asynchronous image detection and annotation for a list of generic - // files, such as PDF files, which may contain multiple pages and multiple - // images per page. Progress and results can be retrieved through the - // `google.longrunning.Operations` interface. - // `Operation.metadata` contains `OperationMetadata` (metadata). - // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/files:asyncBatchAnnotate" - body: "*" - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "AsyncBatchAnnotateFilesResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// The type of Google Cloud Vision API detection to perform, and the maximum -// number of results to return for that type. Multiple `Feature` objects can -// be specified in the `features` list. -message Feature { - // Type of Google Cloud Vision API feature to be extracted. - enum Type { - // Unspecified feature type. - TYPE_UNSPECIFIED = 0; - - // Run face detection. - FACE_DETECTION = 1; - - // Run landmark detection. - LANDMARK_DETECTION = 2; - - // Run logo detection. - LOGO_DETECTION = 3; - - // Run label detection. - LABEL_DETECTION = 4; - - // Run text detection / optical character recognition (OCR). Text detection - // is optimized for areas of text within a larger image; if the image is - // a document, use `DOCUMENT_TEXT_DETECTION` instead. - TEXT_DETECTION = 5; - - // Run dense text document OCR. Takes precedence when both - // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present. - DOCUMENT_TEXT_DETECTION = 11; - - // Run Safe Search to detect potentially unsafe - // or undesirable content. - SAFE_SEARCH_DETECTION = 6; - - // Compute a set of image properties, such as the - // image's dominant colors. - IMAGE_PROPERTIES = 7; - - // Run crop hints. - CROP_HINTS = 9; - - // Run web detection. - WEB_DETECTION = 10; - - // Run Product Search. - PRODUCT_SEARCH = 12; - - // Run localizer for object detection. - OBJECT_LOCALIZATION = 19; - } - - // The feature type. - Type type = 1; - - // Maximum number of results of this type. Does not apply to - // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`. - int32 max_results = 2; - - // Model to use for the feature. - // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also - // support "builtin/weekly" for the bleeding edge release updated weekly. - string model = 3; -} - -// External image source (Google Cloud Storage or web URL image location). -message ImageSource { - // **Use `image_uri` instead.** - // - // The 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 gcs_image_uri = 1; - - // The URI of the source image. Can be either: - // - // 1. A 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. - // - // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from - // HTTP/HTTPS URLs, Google cannot guarantee that the request will be - // completed. Your request may fail if the specified host denies the - // request (e.g. due to request throttling or DOS prevention), or if Google - // throttles requests to the site for abuse prevention. You should not - // depend on externally-hosted images for production applications. - // - // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes - // precedence. - string image_uri = 2; -} - -// Client image to perform Google Cloud Vision API tasks over. -message Image { - // Image 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 = 1; - - // Google Cloud Storage image location, or publicly-accessible image - // URL. If both `content` and `source` are provided for an image, `content` - // takes precedence and is used to perform the image annotation request. - ImageSource source = 2; -} - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely. - VERY_UNLIKELY = 1; - - // It is unlikely. - UNLIKELY = 2; - - // It is possible. - POSSIBLE = 3; - - // It is likely. - LIKELY = 4; - - // It is very likely. - VERY_LIKELY = 5; -} - -// A face annotation object contains the results of face detection. -message FaceAnnotation { - // A face-specific landmark (for example, a face feature). - message Landmark { - // Face landmark (feature) type. - // Left and right are defined from the vantage of the viewer of the image - // without considering mirror projections typical of photos. So, `LEFT_EYE`, - // typically, is the person's right eye. - enum Type { - // Unknown face landmark detected. Should not be filled. - UNKNOWN_LANDMARK = 0; - - // Left eye. - LEFT_EYE = 1; - - // Right eye. - RIGHT_EYE = 2; - - // Left of left eyebrow. - LEFT_OF_LEFT_EYEBROW = 3; - - // Right of left eyebrow. - RIGHT_OF_LEFT_EYEBROW = 4; - - // Left of right eyebrow. - LEFT_OF_RIGHT_EYEBROW = 5; - - // Right of right eyebrow. - RIGHT_OF_RIGHT_EYEBROW = 6; - - // Midpoint between eyes. - MIDPOINT_BETWEEN_EYES = 7; - - // Nose tip. - NOSE_TIP = 8; - - // Upper lip. - UPPER_LIP = 9; - - // Lower lip. - LOWER_LIP = 10; - - // Mouth left. - MOUTH_LEFT = 11; - - // Mouth right. - MOUTH_RIGHT = 12; - - // Mouth center. - MOUTH_CENTER = 13; - - // Nose, bottom right. - NOSE_BOTTOM_RIGHT = 14; - - // Nose, bottom left. - NOSE_BOTTOM_LEFT = 15; - - // Nose, bottom center. - NOSE_BOTTOM_CENTER = 16; - - // Left eye, top boundary. - LEFT_EYE_TOP_BOUNDARY = 17; - - // Left eye, right corner. - LEFT_EYE_RIGHT_CORNER = 18; - - // Left eye, bottom boundary. - LEFT_EYE_BOTTOM_BOUNDARY = 19; - - // Left eye, left corner. - LEFT_EYE_LEFT_CORNER = 20; - - // Right eye, top boundary. - RIGHT_EYE_TOP_BOUNDARY = 21; - - // Right eye, right corner. - RIGHT_EYE_RIGHT_CORNER = 22; - - // Right eye, bottom boundary. - RIGHT_EYE_BOTTOM_BOUNDARY = 23; - - // Right eye, left corner. - RIGHT_EYE_LEFT_CORNER = 24; - - // Left eyebrow, upper midpoint. - LEFT_EYEBROW_UPPER_MIDPOINT = 25; - - // Right eyebrow, upper midpoint. - RIGHT_EYEBROW_UPPER_MIDPOINT = 26; - - // Left ear tragion. - LEFT_EAR_TRAGION = 27; - - // Right ear tragion. - RIGHT_EAR_TRAGION = 28; - - // Left eye pupil. - LEFT_EYE_PUPIL = 29; - - // Right eye pupil. - RIGHT_EYE_PUPIL = 30; - - // Forehead glabella. - FOREHEAD_GLABELLA = 31; - - // Chin gnathion. - CHIN_GNATHION = 32; - - // Chin left gonion. - CHIN_LEFT_GONION = 33; - - // Chin right gonion. - CHIN_RIGHT_GONION = 34; - } - - // Face landmark type. - Type type = 3; - - // Face landmark position. - Position position = 4; - } - - // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale. - // The bounding box is computed to "frame" the face in accordance with human - // expectations. It is based on the landmarker results. - // Note that one or more x and/or y coordinates may not be generated in the - // `BoundingPoly` (the polygon will be unbounded) if only a partial face - // appears in the image to be annotated. - BoundingPoly bounding_poly = 1; - - // The `fd_bounding_poly` bounding polygon is tighter than the - // `boundingPoly`, and encloses only the skin part of the face. Typically, it - // is used to eliminate the face from any image analysis that detects the - // "amount of skin" visible in an image. It is not based on the - // landmarker results, only on the initial face detection, hence - // the fd (face detection) prefix. - BoundingPoly fd_bounding_poly = 2; - - // Detected face landmarks. - repeated Landmark landmarks = 3; - - // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation - // of the face relative to the image vertical about the axis perpendicular to - // the face. Range [-180,180]. - float roll_angle = 4; - - // Yaw angle, which indicates the leftward/rightward angle that the face is - // pointing relative to the vertical plane perpendicular to the image. Range - // [-180,180]. - float pan_angle = 5; - - // Pitch angle, which indicates the upwards/downwards angle that the face is - // pointing relative to the image's horizontal plane. Range [-180,180]. - float tilt_angle = 6; - - // Detection confidence. Range [0, 1]. - float detection_confidence = 7; - - // Face landmarking confidence. Range [0, 1]. - float landmarking_confidence = 8; - - // Joy likelihood. - Likelihood joy_likelihood = 9; - - // Sorrow likelihood. - Likelihood sorrow_likelihood = 10; - - // Anger likelihood. - Likelihood anger_likelihood = 11; - - // Surprise likelihood. - Likelihood surprise_likelihood = 12; - - // Under-exposed likelihood. - Likelihood under_exposed_likelihood = 13; - - // Blurred likelihood. - Likelihood blurred_likelihood = 14; - - // Headwear likelihood. - Likelihood headwear_likelihood = 15; - - // Additional recognition information. Only computed if - // image_context.face_recognition_params is provided, **and** a match is found - // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input - // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is - // sorted in order of decreasing confidence values. - repeated FaceRecognitionResult recognition_result = 16; -} - -// Detected entity location information. -message LocationInfo { - // lat/long location coordinates. - google.type.LatLng lat_lng = 1; -} - -// A `Property` consists of a user-supplied name/value pair. -message Property { - // Name of the property. - string name = 1; - - // Value of the property. - string value = 2; - - // Value of numeric properties. - uint64 uint64_value = 3; -} - -// Set of detected entity features. -message EntityAnnotation { - // Opaque entity ID. Some IDs may be available in - // [Google Knowledge Graph Search - // API](https://developers.google.com/knowledge-graph/). - string mid = 1; - - // The language code for the locale in which the entity textual - // `description` is expressed. - string locale = 2; - - // Entity textual description, expressed in its `locale` language. - string description = 3; - - // Overall score of the result. Range [0, 1]. - float score = 4; - - // **Deprecated. Use `score` instead.** - // The accuracy of the entity detection in an image. - // For example, for an image in which the "Eiffel Tower" entity is detected, - // this field represents the confidence that there is a tower in the query - // image. Range [0, 1]. - float confidence = 5 [deprecated = true]; - - // The relevancy of the ICA (Image Content Annotation) label to the - // image. For example, the relevancy of "tower" is likely higher to an image - // containing the detected "Eiffel Tower" than to an image containing a - // detected distant towering building, even though the confidence that - // there is a tower in each image may be the same. Range [0, 1]. - float topicality = 6; - - // Image region to which this entity belongs. Not produced - // for `LABEL_DETECTION` features. - BoundingPoly bounding_poly = 7; - - // The location information for the detected entity. Multiple - // `LocationInfo` elements can be present because one location may - // indicate the location of the scene in the image, and another location - // may indicate the location of the place where the image was taken. - // Location information is usually present for landmarks. - repeated LocationInfo locations = 8; - - // Some entities may have optional user-supplied `Property` (name/value) - // fields, such a score or string that qualifies the entity. - repeated Property properties = 9; -} - -// Set of detected objects with bounding boxes. -message LocalizedObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - - // Image region to which this object belongs. This must be populated. - BoundingPoly bounding_poly = 5; -} - -// Set of features pertaining to the image, computed by computer vision -// methods over safe-search verticals (for example, adult, spoof, medical, -// violence). -message SafeSearchAnnotation { - // Represents the adult content likelihood for the image. Adult content may - // contain elements such as nudity, pornographic images or cartoons, or - // sexual activities. - Likelihood adult = 1; - - // Spoof likelihood. The likelihood that an modification - // was made to the image's canonical version to make it appear - // funny or offensive. - Likelihood spoof = 2; - - // Likelihood that this is a medical image. - Likelihood medical = 3; - - // Likelihood that this image contains violent content. - Likelihood violence = 4; - - // Likelihood that the request image contains racy content. Racy content may - // include (but is not limited to) skimpy or sheer clothing, strategically - // covered nudity, lewd or provocative poses, or close-ups of sensitive - // body areas. - Likelihood racy = 9; -} - -// Rectangle determined by min and max `LatLng` pairs. -message LatLongRect { - // Min lat/long pair. - google.type.LatLng min_lat_lng = 1; - - // Max lat/long pair. - google.type.LatLng max_lat_lng = 2; -} - -// Color information consists of RGB channels, score, and the fraction of -// the image that the color occupies in the image. -message ColorInfo { - // RGB components of the color. - google.type.Color color = 1; - - // Image-specific score for this color. Value in range [0, 1]. - float score = 2; - - // The fraction of pixels the color occupies in the image. - // Value in range [0, 1]. - float pixel_fraction = 3; -} - -// Set of dominant colors and their corresponding scores. -message DominantColorsAnnotation { - // RGB color values with their score and pixel fraction. - repeated ColorInfo colors = 1; -} - -// Stores image properties, such as dominant colors. -message ImageProperties { - // If present, dominant colors completed successfully. - DominantColorsAnnotation dominant_colors = 1; -} - -// Single crop hint that is used to generate a new crop when serving an image. -message CropHint { - // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale. - BoundingPoly bounding_poly = 1; - - // Confidence of this being a salient region. Range [0, 1]. - float confidence = 2; - - // Fraction of importance of this salient region with respect to the original - // image. - float importance_fraction = 3; -} - -// Set of crop hints that are used to generate new crops when serving images. -message CropHintsAnnotation { - // Crop hint results. - repeated CropHint crop_hints = 1; -} - -// Parameters for crop hints annotation request. -message CropHintsParams { - // Aspect ratios in floats, representing the ratio of the width to the height - // of the image. For example, if the desired aspect ratio is 4/3, the - // corresponding float value should be 1.33333. If not specified, the - // best possible crop is returned. The number of provided aspect ratios is - // limited to a maximum of 16; any aspect ratios provided after the 16th are - // ignored. - repeated float aspect_ratios = 1; -} - -// Parameters for web detection request. -message WebDetectionParams { - // Whether to include results derived from the geo information in the image. - bool include_geo_results = 2; -} - -// Parameters for text detections. This is used to control TEXT_DETECTION and -// DOCUMENT_TEXT_DETECTION features. -message TextDetectionParams { - - // By default, Cloud Vision API only includes confidence score for - // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence - // score for TEXT_DETECTION as well. - bool enable_text_detection_confidence_score = 9; - - // A list of advanced OCR options to fine-tune OCR behavior. - repeated string advanced_ocr_options = 11; -} - -// Image context and/or feature-specific parameters. -message ImageContext { - // Not used. - LatLongRect lat_long_rect = 1; - - // List of languages to use for TEXT_DETECTION. 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). Text detection returns an - // error if one or more of the specified languages is not one of the - // [supported languages](https://cloud.google.com/vision/docs/languages). - repeated string language_hints = 2; - - // Parameters for crop hints annotation request. - CropHintsParams crop_hints_params = 4; - - // Parameters for face recognition. - FaceRecognitionParams face_recognition_params = 10; - - // Parameters for product search. - ProductSearchParams product_search_params = 5; - - // Parameters for web detection. - WebDetectionParams web_detection_params = 6; - - // Parameters for text detection and document text detection. - TextDetectionParams text_detection_params = 12; -} - -// Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features, and with context information. -message AnnotateImageRequest { - // The image to be processed. - Image image = 1; - - // Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image. - ImageContext image_context = 3; -} - -// If an image was produced from a file (e.g. a PDF), this message gives -// information about the source of that image. -message ImageAnnotationContext { - // The URI of the file used to produce the image. - string uri = 1; - - // If the file was a PDF or TIFF, this field gives the page number within - // the file used to produce the image. - int32 page_number = 2; -} - -// Response to an image annotation request. -message AnnotateImageResponse { - // If present, face detection has completed successfully. - repeated FaceAnnotation face_annotations = 1; - - // If present, landmark detection has completed successfully. - repeated EntityAnnotation landmark_annotations = 2; - - // If present, logo detection has completed successfully. - repeated EntityAnnotation logo_annotations = 3; - - // If present, label detection has completed successfully. - repeated EntityAnnotation label_annotations = 4; - - // If present, localized object detection has completed successfully. - // This will be sorted descending by confidence score. - repeated LocalizedObjectAnnotation localized_object_annotations = 22; - - // If present, text (OCR) detection has completed successfully. - repeated EntityAnnotation text_annotations = 5; - - // If present, text (OCR) detection or document (OCR) text detection has - // completed successfully. - // This annotation provides the structural hierarchy for the OCR detected - // text. - TextAnnotation full_text_annotation = 12; - - // If present, safe-search annotation has completed successfully. - SafeSearchAnnotation safe_search_annotation = 6; - - // If present, image properties were extracted successfully. - ImageProperties image_properties_annotation = 8; - - // If present, crop hints have completed successfully. - CropHintsAnnotation crop_hints_annotation = 11; - - // If present, web detection has completed successfully. - WebDetection web_detection = 13; - - // If present, product search has completed successfully. - ProductSearchResults product_search_results = 14; - - // If set, represents the error message for the operation. - // Note that filled-in image annotations are guaranteed to be - // correct, even when `error` is set. - google.rpc.Status error = 9; - - // If present, contextual information is needed to understand where this image - // comes from. - ImageAnnotationContext context = 21; -} - -// Multiple image annotation requests are batched into a single service call. -message BatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to a batch image annotation request. -message BatchAnnotateImagesResponse { - // Individual responses to image annotation requests within the batch. - repeated AnnotateImageResponse responses = 1; -} - -// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. -message AnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Pages of the file to perform image annotation. - // - // Pages starts from 1, we assume the first page of the file is page 1. - // At most 5 pages are supported per request. Pages can be negative. - // - // Page 1 means the first page. - // Page 2 means the second page. - // Page -1 means the last page. - // Page -2 means the second to the last page. - // - // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. - // - // If this field is empty, by default the service performs image annotation - // for the first 5 pages of the file. - repeated int32 pages = 4; -} - -// Response to a single file annotation request. A file may contain one or more -// images, which individually have their own responses. -message AnnotateFileResponse { - // Information about the file for which this response is generated. - InputConfig input_config = 1; - - // Individual responses to images found within the file. This field will be - // empty if the `error` field is set. - repeated AnnotateImageResponse responses = 2; - - // This field gives the total number of pages in the file. - int32 total_pages = 3; - - // If set, represents the error message for the failed request. The - // `responses` field will not be set in this case. - google.rpc.Status error = 4; -} - -// A list of requests to annotate files using the BatchAnnotateFiles API. -message BatchAnnotateFilesRequest { - // Required. The list of file annotation requests. Right now we support only - // one AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// A list of file annotation responses. -message BatchAnnotateFilesResponse { - // The list of file annotation responses, each response corresponding to each - // AnnotateFileRequest in BatchAnnotateFilesRequest. - repeated AnnotateFileResponse responses = 1; -} - -// An offline file annotation request. -message AsyncAnnotateFileRequest { - // Required. Information about the input file. - InputConfig input_config = 1; - - // Required. Requested features. - repeated Feature features = 2; - - // Additional context that may accompany the image(s) in the file. - ImageContext image_context = 3; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 4; -} - -// The response for a single offline file annotation request. -message AsyncAnnotateFileResponse { - // The output location and metadata from AsyncAnnotateFileRequest. - OutputConfig output_config = 1; -} - -// Request for async image annotation for a list of images. -message AsyncBatchAnnotateImagesRequest { - // Required. Individual image annotation requests for this batch. - repeated AnnotateImageRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location and metadata (e.g. format). - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch image annotation request. -message AsyncBatchAnnotateImagesResponse { - // The output location and metadata from AsyncBatchAnnotateImagesRequest. - OutputConfig output_config = 1; -} - -// Multiple async file annotation requests are batched into a single service -// call. -message AsyncBatchAnnotateFilesRequest { - // Required. Individual async file annotation requests for this batch. - repeated AsyncAnnotateFileRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response to an async batch file annotation request. -message AsyncBatchAnnotateFilesResponse { - // The list of file annotation responses, one for each request in - // AsyncBatchAnnotateFilesRequest. - repeated AsyncAnnotateFileResponse responses = 1; -} - -// The desired input location and metadata. -message InputConfig { - // The Google Cloud Storage location to read the input from. - GcsSource gcs_source = 1; - - // File content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - // - // Currently, this field only works for BatchAnnotateFiles requests. It does - // not work for AsyncBatchAnnotateFiles requests. - bytes content = 3; - - // The type of the file. Currently only "application/pdf", "image/tiff" and - // "image/gif" are supported. Wildcards are not supported. - string mime_type = 2; -} - -// The desired output location and metadata. -message OutputConfig { - // The Google Cloud Storage location to write the output(s) to. - GcsDestination gcs_destination = 1; - - // The max number of response protos to put into each output JSON file 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 response protos will - // be generated. If `batch_size` = 20, then 5 json files each - // containing 20 response protos will be written under the prefix - // `gcs_destination`.`uri`. - // - // Currently, batch_size only applies to GcsDestination, with potential future - // support for other output configurations. - int32 batch_size = 2; -} - -// The Google Cloud Storage location where the input will be read from. -message GcsSource { - // Google Cloud Storage URI for the input file. This must only be a - // Google Cloud Storage object. Wildcards are not currently supported. - string uri = 1; -} - -// The Google Cloud Storage location where the output will be written to. -message GcsDestination { - // Google Cloud Storage URI prefix where the results will be stored. Results - // will be in JSON format and preceded by its corresponding input URI prefix. - // This field can either represent a gcs file prefix or gcs directory. In - // either case, the uri should be unique because in order to get all of the - // output files, you will need to do a wildcard gcs search on the uri prefix - // you provide. - // - // Examples: - // - // * File Prefix: gs://bucket-name/here/filenameprefix The output files - // will be created in gs://bucket-name/here/ and the names of the - // output files will begin with "filenameprefix". - // - // * Directory Prefix: gs://bucket-name/some/location/ The output files - // will be created in gs://bucket-name/some/location/ and the names of the - // output files could be anything because there was no filename prefix - // specified. - // - // If multiple outputs, each response is still AnnotateFileResponse, each of - // which contains some subset of the full list of AnnotateImageResponse. - // Multiple outputs can happen if, for example, the output JSON is too large - // and overflows into multiple sharded files. - string uri = 1; -} - -// Contains metadata for the BatchAnnotateImages operation. -message OperationMetadata { - // Batch operation states. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is received. - CREATED = 1; - - // Request is actively being processed. - RUNNING = 2; - - // The batch processing is done. - DONE = 3; - - // The batch processing was cancelled. - CANCELLED = 4; - } - - // Current state of the batch operation. - State state = 1; - - // The time when the batch request was received. - google.protobuf.Timestamp create_time = 5; - - // The time when the operation result was last updated. - google.protobuf.Timestamp update_time = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto deleted file mode 100644 index ebb428ac..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search.proto +++ /dev/null @@ -1,127 +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.vision.v1p4beta1; - -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/cloud/vision/v1p4beta1/product_search_service.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Parameters for a product search request. -message ProductSearchParams { - // The bounding polygon around the area of interest in the image. - // If it is not specified, system discretion will be applied. - BoundingPoly bounding_poly = 9; - - // The resource name of a - // [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] to be searched for - // similar images. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - string product_set = 6 [(google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - }]; - - // The list of product categories to search in. Currently, we only consider - // the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", - // "packagedgoods-v1", or "general-v1" should be specified. The legacy - // categories "homegoods", "apparel", and "toys" are still supported but will - // be deprecated. For new products, please use "homegoods-v2", "apparel-v2", - // or "toys-v2" for better product search accuracy. It is recommended to - // migrate existing products to these categories as well. - repeated string product_categories = 7; - - // The filtering expression. This can be used to restrict search results based - // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. An - // '=' should be used to connect the key and value. - // - // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but "(color = red OR brand = Google)" is not acceptable. - // "color: red" is not acceptable because it uses a ':' instead of an '='. - string filter = 8; -} - -// Results for a product search request. -message ProductSearchResults { - // Information about a product. - message Result { - // The Product. - Product product = 1; - - // A confidence level on the match, ranging from 0 (no confidence) to - // 1 (full confidence). - float score = 2; - - // The resource name of the image from the product that is the closest match - // to the query. - string image = 3; - } - - // Prediction for what the object in the bounding box is. - message ObjectAnnotation { - // Object ID that should align with EntityAnnotation mid. - string mid = 1; - - // 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 = 2; - - // Object name, expressed in its `language_code` language. - string name = 3; - - // Score of the result. Range [0, 1]. - float score = 4; - } - - // Information about the products similar to a single product in a query - // image. - message GroupedResult { - // The bounding polygon around the product detected in the query image. - BoundingPoly bounding_poly = 1; - - // List of results, one for each product match. - repeated Result results = 2; - - // List of generic predictions for the object in the bounding box. - repeated ObjectAnnotation object_annotations = 3; - } - - // Timestamp of the index which provided these results. Products added to the - // product set and products removed from the product set after this time are - // not reflected in the current results. - google.protobuf.Timestamp index_time = 2; - - // List of results, one for each product match. - repeated Result results = 5; - - // List of results grouped by products detected in the query image. Each entry - // corresponds to one bounding polygon in the query image, and contains the - // matching products specific to that region. There may be duplicate product - // matches in the union of all the per-product results. - repeated GroupedResult product_grouped_results = 6; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto deleted file mode 100644 index df7bc7a3..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/product_search_service.proto +++ /dev/null @@ -1,1039 +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.vision.v1p4beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/vision/v1p4beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "ProductSearchServiceProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Manages Products and ProductSets of reference images for use in product -// search. It uses the following resource model: -// -// - The API has a collection of -// [ProductSet][google.cloud.vision.v1p4beta1.ProductSet] resources, named -// `projects/*/locations/*/productSets/*`, which acts as a way to put different -// products into groups to limit identification. -// -// In parallel, -// -// - The API has a collection of -// [Product][google.cloud.vision.v1p4beta1.Product] resources, named -// `projects/*/locations/*/products/*` -// -// - Each [Product][google.cloud.vision.v1p4beta1.Product] has a collection of -// [ReferenceImage][google.cloud.vision.v1p4beta1.ReferenceImage] resources, -// named -// `projects/*/locations/*/products/*/referenceImages/*` -service ProductSearch { - option (google.api.default_host) = "vision.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-vision"; - - // Creates and returns a new ProductSet resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - // 4096 characters. - rpc CreateProductSet(CreateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - body: "product_set" - }; - option (google.api.method_signature) = "parent,product_set,product_set_id"; - } - - // Lists ProductSets in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - // than 1. - rpc ListProductSets(ListProductSetsRequest) - returns (ListProductSetsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/productSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - rpc GetProductSet(GetProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a ProductSet resource. - // Only display_name can be updated currently. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but - // missing from the request or longer than 4096 characters. - rpc UpdateProductSet(UpdateProductSetRequest) returns (ProductSet) { - option (google.api.http) = { - patch: "/v1p4beta1/{product_set.name=projects/*/locations/*/productSets/*}" - body: "product_set" - }; - option (google.api.method_signature) = "product_set,update_mask"; - } - - // Permanently deletes a ProductSet. Products and ReferenceImages in the - // ProductSet are not deleted. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteProductSet(DeleteProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new product resource. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is missing or invalid. - rpc CreateProduct(CreateProductRequest) returns (Product) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products" - body: "product" - }; - option (google.api.method_signature) = "parent,product,product_id"; - } - - // Lists products in an unspecified order. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*}/products" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a Product. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - rpc GetProduct(GetProductRequest) returns (Product) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Makes changes to a Product resource. - // Only the `display_name`, `description`, and `labels` fields can be updated - // right now. - // - // If labels are updated, the change will not be reflected in queries until - // the next index time. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product does not exist. - // * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - // missing from the request or longer than 4096 characters. - // * Returns INVALID_ARGUMENT if description is present in update_mask but is - // longer than 4096 characters. - // * Returns INVALID_ARGUMENT if product_category is present in update_mask. - rpc UpdateProduct(UpdateProductRequest) returns (Product) { - option (google.api.http) = { - patch: "/v1p4beta1/{product.name=projects/*/locations/*/products/*}" - body: "product" - }; - option (google.api.method_signature) = "product,update_mask"; - } - - // Permanently deletes a product and its reference images. - // - // Metadata of the product and all its images will be deleted right away, but - // search queries against ProductSets containing the product may still work - // until all related caches are refreshed. - rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates and returns a new ReferenceImage resource. - // - // The `bounding_poly` field is optional. If `bounding_poly` is not specified, - // the system will try to detect regions of interest in the image that are - // compatible with the product_category on the parent product. If it is - // specified, detection is ALWAYS skipped. The system converts polygons into - // non-rotated rectangles. - // - // Note that the pipeline will resize the image if the image resolution is too - // large to process (above 50MP). - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - // characters. - // * Returns INVALID_ARGUMENT if the product does not exist. - // * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - // compatible with the parent product's product_category is detected. - // * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - rpc CreateReferenceImage(CreateReferenceImageRequest) - returns (ReferenceImage) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - body: "reference_image" - }; - option (google.api.method_signature) = - "parent,reference_image,reference_image_id"; - } - - // Permanently deletes a reference image. - // - // The image metadata will be deleted right away, but search queries - // against ProductSets containing the image may still work until all related - // caches are refreshed. - // - // The actual image files are not deleted from Google Cloud Storage. - rpc DeleteReferenceImage(DeleteReferenceImageRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists reference images. - // - // Possible errors: - // - // * Returns NOT_FOUND if the parent product does not exist. - // * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - // than 1. - rpc ListReferenceImages(ListReferenceImagesRequest) - returns (ListReferenceImagesResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{parent=projects/*/locations/*/products/*}/referenceImages" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets information associated with a ReferenceImage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the specified image does not exist. - rpc GetReferenceImage(GetReferenceImageRequest) returns (ReferenceImage) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/products/*/referenceImages/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Adds a Product to the specified ProductSet. If the Product is already - // present, no change is made. - // - // One Product can be added to at most 100 ProductSets. - // - // Possible errors: - // - // * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - rpc AddProductToProductSet(AddProductToProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:addProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Removes a Product from the specified ProductSet. - rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}:removeProduct" - body: "*" - }; - option (google.api.method_signature) = "name,product"; - } - - // Lists the Products in a ProductSet, in an unspecified order. If the - // ProductSet does not exist, the products field of the response will be - // empty. - // - // Possible errors: - // - // * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - rpc ListProductsInProductSet(ListProductsInProductSetRequest) - returns (ListProductsInProductSetResponse) { - option (google.api.http) = { - get: "/v1p4beta1/{name=projects/*/locations/*/productSets/*}/products" - }; - option (google.api.method_signature) = "name"; - } - - // Asynchronous API that imports a list of reference images to specified - // product sets based on a list of image information. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - // `Operation.response` contains `ImportProductSetsResponse`. (results) - // - // The input source of this method is a csv file on Google Cloud Storage. - // For the format of the csv file please see - // [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri]. - rpc ImportProductSets(ImportProductSetsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/productSets:import" - body: "*" - }; - option (google.api.method_signature) = "parent,input_config"; - option (google.longrunning.operation_info) = { - response_type: "ImportProductSetsResponse" - metadata_type: "BatchOperationMetadata" - }; - } - - // Asynchronous API to delete all Products in a ProductSet or all Products - // that are in no ProductSet. - // - // If a Product is a member of the specified ProductSet in addition to other - // ProductSets, the Product will still be deleted. - // - // It is recommended to not delete the specified ProductSet until after this - // operation has completed. It is also recommended to not add any of the - // Products involved in the batch delete to a new ProductSet while this - // operation is running because those Products may still end up deleted. - // - // It's not possible to undo the PurgeProducts operation. Therefore, it is - // recommended to keep the csv files used in ImportProductSets (if that was - // how you originally built the Product Set) before starting PurgeProducts, in - // case you need to re-import the data after deletion. - // - // If the plan is to purge all of the Products from a ProductSet and then - // re-use the empty ProductSet to re-import new Products into the empty - // ProductSet, you must wait until the PurgeProducts operation has finished - // for that ProductSet. - // - // The [google.longrunning.Operation][google.longrunning.Operation] API can be - // used to keep track of the progress and results of the request. - // `Operation.metadata` contains `BatchOperationMetadata`. (progress) - rpc PurgeProducts(PurgeProductsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p4beta1/{parent=projects/*/locations/*}/products:purge" - body: "*" - }; - option (google.api.method_signature) = "parent"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "BatchOperationMetadata" - }; - } -} - -// A Product contains ReferenceImages. -message Product { - option (google.api.resource) = { - type: "vision.googleapis.com/Product" - pattern: "projects/{project}/locations/{location}/products/{product}" - }; - - // A product label represented as a key-value pair. - message KeyValue { - // The key of the label attached to the product. Cannot be empty and cannot - // exceed 128 bytes. - string key = 1; - - // The value of the label attached to the product. Cannot be empty and - // cannot exceed 128 bytes. - string value = 2; - } - - // The resource name of the product. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - // - // This field is ignored when creating a product. - string name = 1; - - // The user-provided name for this Product. Must not be empty. Must be at most - // 4096 characters long. - string display_name = 2; - - // User-provided metadata to be stored with this product. Must be at most 4096 - // characters long. - string description = 3; - - // Immutable. The category for the product identified by the reference image. - // This should be either "homegoods-v2", "apparel-v2", or "toys-v2". The - // legacy categories "homegoods", "apparel", and "toys" are still supported, - // but these should not be used for new products. - string product_category = 4 [(google.api.field_behavior) = IMMUTABLE]; - - // Key-value pairs that can be attached to a product. At query time, - // constraints can be specified based on the product_labels. - // - // Note that integer values can be provided as strings, e.g. "1199". Only - // strings with integer values can match a range-based restriction which is - // to be supported soon. - // - // Multiple values can be assigned to the same key. One product may have up to - // 500 product_labels. - // - // Notice that the total number of distinct product_labels over all products - // in one ProductSet cannot exceed 1M, otherwise the product search pipeline - // will refuse to work for that ProductSet. - repeated KeyValue product_labels = 5; -} - -// A ProductSet contains Products. A ProductSet can contain a maximum of 1 -// million reference images. If the limit is exceeded, periodic indexing will -// fail. -message ProductSet { - option (google.api.resource) = { - type: "vision.googleapis.com/ProductSet" - pattern: "projects/{project}/locations/{location}/productSets/{product_set}" - }; - - // The resource name of the ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. - // - // This field is ignored when creating a ProductSet. - string name = 1; - - // The user-provided name for this ProductSet. Must not be empty. Must be at - // most 4096 characters long. - string display_name = 2; - - // Output only. The time at which this ProductSet was last indexed. Query - // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this timestamp is the default value - // "1970-01-01T00:00:00Z". - // - // This field is ignored when creating a ProductSet. - google.protobuf.Timestamp index_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If there was an error with indexing the product set, the field - // is populated. - // - // This field is ignored when creating a ProductSet. - google.rpc.Status index_error = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A `ReferenceImage` represents a product image and its associated metadata, -// such as bounding boxes. -message ReferenceImage { - option (google.api.resource) = { - type: "vision.googleapis.com/ReferenceImage" - pattern: "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}" - }; - - // The resource name of the reference image. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - // - // This field is ignored when creating a reference image. - string name = 1; - - // Required. The Google Cloud Storage URI of the reference image. - // - // The URI must start with `gs://`. - string uri = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Bounding polygons around the areas of interest in the reference - // image. If this field is empty, the system will try to detect regions of - // interest. At most 10 bounding polygons will be used. - // - // The provided shape is converted into a non-rotated rectangle. Once - // converted, the small edge of the rectangle must be greater than or equal - // to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 - // is not). - repeated BoundingPoly bounding_polys = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request message for the `CreateProduct` method. -message CreateProductRequest { - // Required. The project in which the Product should be created. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The product to create. - Product product = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this Product. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_id = 3; -} - -// Request message for the `ListProducts` method. -message ListProductsRequest { - // Required. The project OR ProductSet from which Products should be listed. - // - // Format: - // `projects/PROJECT_ID/locations/LOC_ID` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProducts` method. -message ListProductsResponse { - // List of products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProduct` method. -message GetProductRequest { - // Required. Resource name of the Product to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `UpdateProduct` method. -message UpdateProductRequest { - // Required. The Product resource which replaces the one on the server. - // product.name is immutable. - Product product = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields - // to update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask paths include `product_labels`, `display_name`, and - // `description`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProduct` method. -message DeleteProductRequest { - // Required. Resource name of product to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `CreateProductSet` method. -message CreateProductSetRequest { - // Required. The project in which the ProductSet should be created. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The ProductSet to create. - ProductSet product_set = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for this ProductSet. If set, the server will - // attempt to use this value as the resource id. If it is already in use, an - // error is returned with code ALREADY_EXISTS. Must be at most 128 characters - // long. It cannot contain the character `/`. - string product_set_id = 3; -} - -// Request message for the `ListProductSets` method. -message ListProductSetsRequest { - // Required. The project from which ProductSets should be listed. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductSets` method. -message ListProductSetsResponse { - // List of ProductSets. - repeated ProductSet product_sets = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// Request message for the `GetProductSet` method. -message GetProductSetRequest { - // Required. Resource name of the ProductSet to get. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `UpdateProductSet` method. -message UpdateProductSetRequest { - // Required. The ProductSet resource which replaces the one on the server. - ProductSet product_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The [FieldMask][google.protobuf.FieldMask] that specifies which fields to - // update. - // If update_mask isn't specified, all mutable fields are to be updated. - // Valid mask path is `display_name`. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for the `DeleteProductSet` method. -message DeleteProductSetRequest { - // Required. Resource name of the ProductSet to delete. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; -} - -// Request message for the `CreateReferenceImage` method. -message CreateReferenceImageRequest { - // Required. Resource name of the product in which to create the reference - // image. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // Required. The reference image to create. - // If an image ID is specified, it is ignored. - ReferenceImage reference_image = 2 [(google.api.field_behavior) = REQUIRED]; - - // A user-supplied resource id for the ReferenceImage to be added. If set, - // the server will attempt to use this value as the resource id. If it is - // already in use, an error is returned with code ALREADY_EXISTS. Must be at - // most 128 characters long. It cannot contain the character `/`. - string reference_image_id = 3; -} - -// Request message for the `ListReferenceImages` method. -message ListReferenceImagesRequest { - // Required. Resource name of the product containing the reference images. - // - // Format is - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This is the value - // of `nextPageToken` returned in a previous reference image list request. - // - // Defaults to the first page if not specified. - string page_token = 3; -} - -// Response message for the `ListReferenceImages` method. -message ListReferenceImagesResponse { - // The list of reference images. - repeated ReferenceImage reference_images = 1; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string next_page_token = 3; -} - -// Request message for the `GetReferenceImage` method. -message GetReferenceImageRequest { - // Required. The resource name of the ReferenceImage to get. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `DeleteReferenceImage` method. -message DeleteReferenceImageRequest { - // Required. The resource name of the reference image to delete. - // - // Format is: - // - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ReferenceImage" - } - ]; -} - -// Request message for the `AddProductToProductSet` method. -message AddProductToProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be added to this ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `RemoveProductFromProductSet` method. -message RemoveProductFromProductSetRequest { - // Required. The resource name for the ProductSet to modify. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // Required. The resource name for the Product to be removed from this - // ProductSet. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - string product = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "vision.googleapis.com/Product" } - ]; -} - -// Request message for the `ListProductsInProductSet` method. -message ListProductsInProductSetRequest { - // Required. The ProductSet resource for which to retrieve Products. - // - // Format is: - // `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "vision.googleapis.com/ProductSet" - } - ]; - - // The maximum number of items to return. Default 10, maximum 100. - int32 page_size = 2; - - // The next_page_token returned from a previous List request, if any. - string page_token = 3; -} - -// Response message for the `ListProductsInProductSet` method. -message ListProductsInProductSetResponse { - // The list of Products. - repeated Product products = 1; - - // Token to retrieve the next page of results, or empty if there are no more - // results in the list. - string next_page_token = 2; -} - -// The Google Cloud Storage location for a csv file which preserves a list of -// ImportProductSetRequests in each line. -message ImportProductSetsGcsSource { - // The Google Cloud Storage URI of the input csv file. - // - // The URI must start with `gs://`. - // - // The format of the input csv file should be one image per line. - // In each line, there are 8 columns. - // - // 1. image-uri - // 2. image-id - // 3. product-set-id - // 4. product-id - // 5. product-category - // 6. product-display-name - // 7. labels - // 8. bounding-poly - // - // The `image-uri`, `product-set-id`, `product-id`, and `product-category` - // columns are required. All other columns are optional. - // - // If the `ProductSet` or `Product` specified by the `product-set-id` and - // `product-id` values does not exist, then the system will create a new - // `ProductSet` or `Product` for the image. In this case, the - // `product-display-name` column refers to - // [display_name][google.cloud.vision.v1p4beta1.Product.display_name], the - // `product-category` column refers to - // [product_category][google.cloud.vision.v1p4beta1.Product.product_category], - // and the `labels` column refers to - // [product_labels][google.cloud.vision.v1p4beta1.Product.product_labels]. - // - // The `image-id` column is optional but must be unique if provided. If it is - // empty, the system will automatically assign a unique id to the image. - // - // The `product-display-name` column is optional. If it is empty, the system - // sets the [display_name][google.cloud.vision.v1p4beta1.Product.display_name] - // field for the product to a space (" "). You can update the `display_name` - // later by using the API. - // - // If a `Product` with the specified `product-id` already exists, then the - // system ignores the `product-display-name`, `product-category`, and `labels` - // columns. - // - // The `labels` column (optional) is a line containing a list of - // comma-separated key-value pairs, in the following format: - // - // "key_1=value_1,key_2=value_2,...,key_n=value_n" - // - // The `bounding-poly` column (optional) identifies one region of - // interest from the image in the same manner as `CreateReferenceImage`. If - // you do not specify the `bounding-poly` column, then the system will try to - // detect regions of interest automatically. - // - // At most one `bounding-poly` column is allowed per line. If the image - // contains multiple regions of interest, add a line to the CSV file that - // includes the same product information, and the `bounding-poly` values for - // each region of interest. - // - // The `bounding-poly` column must contain an even number of comma-separated - // numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use - // non-negative integers for absolute bounding polygons, and float values - // in [0, 1] for normalized bounding polygons. - // - // The system will resize the image if the image resolution is too - // large to process (larger than 20MP). - string csv_file_uri = 1; -} - -// The input content for the `ImportProductSets` method. -message ImportProductSetsInputConfig { - // The source of the input. - oneof source { - // The Google Cloud Storage location for a csv file which preserves a list - // of ImportProductSetRequests in each line. - ImportProductSetsGcsSource gcs_source = 1; - } -} - -// Request message for the `ImportProductSets` method. -message ImportProductSetsRequest { - // Required. The project in which the ProductSets should be imported. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The input content for the list of requests. - ImportProductSetsInputConfig input_config = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Response message for the `ImportProductSets` method. -// -// This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] -// method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] -// field. -message ImportProductSetsResponse { - // The list of reference_images that are imported successfully. - repeated ReferenceImage reference_images = 1; - - // The rpc status for each ImportProductSet request, including both successes - // and errors. - // - // The number of statuses here matches the number of lines in the csv file, - // and statuses[i] stores the success or failure status of processing the i-th - // line of the csv, starting from line 0. - repeated google.rpc.Status statuses = 2; -} - -// Metadata for the batch operations such as the current state. -// -// This is included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message BatchOperationMetadata { - // Enumerates the possible states that the batch request can be in. - enum State { - // Invalid. - STATE_UNSPECIFIED = 0; - - // Request is actively being processed. - PROCESSING = 1; - - // The request is done and at least one item has been successfully - // processed. - SUCCESSFUL = 2; - - // The request is done and no item has been successfully processed. - FAILED = 3; - - // The request is done after the longrunning.Operations.CancelOperation has - // been called by the user. Any records that were processed before the - // cancel command are output as specified in the request. - CANCELLED = 4; - } - - // The current state of the batch operation. - State state = 1; - - // The time when the batch request was submitted to the server. - google.protobuf.Timestamp submit_time = 2; - - // The time when the batch request is finished and - // [google.longrunning.Operation.done][google.longrunning.Operation.done] is - // set to true. - google.protobuf.Timestamp end_time = 3; -} - -// Config to control which ProductSet contains the Products to be deleted. -message ProductSetPurgeConfig { - // The ProductSet that contains the Products to delete. If a Product is a - // member of product_set_id in addition to other ProductSets, the Product will - // still be deleted. - string product_set_id = 1; -} - -// Request message for the `PurgeProducts` method. -message PurgeProductsRequest { - // The Products to delete. - oneof target { - // Specify which ProductSet contains the Products to be deleted. - ProductSetPurgeConfig product_set_purge_config = 2; - - // If delete_orphan_products is true, all Products that are not in any - // ProductSet will be deleted. - bool delete_orphan_products = 3; - } - - // Required. The project and location in which the Products should be deleted. - // - // Format is `projects/PROJECT_ID/locations/LOC_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The default value is false. Override this value to true to actually perform - // the purge. - bool force = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto deleted file mode 100644 index 233c4c68..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/text_annotation.proto +++ /dev/null @@ -1,260 +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.vision.v1p4beta1; - -import "google/cloud/vision/v1p4beta1/geometry.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "TextAnnotationProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// TextAnnotation contains a structured representation of OCR extracted text. -// The hierarchy of an OCR extracted text structure is like this: -// TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol -// Each structural component, starting from Page, may further have their own -// properties. Properties describe detected languages, breaks etc.. Please refer -// to the -// [TextAnnotation.TextProperty][google.cloud.vision.v1p4beta1.TextAnnotation.TextProperty] -// message definition below for more detail. -message TextAnnotation { - // 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; - } - - // Detected start or end of a structural component. - message DetectedBreak { - // Enum to denote the type of break found. New line, space etc. - enum BreakType { - // Unknown break label type. - UNKNOWN = 0; - - // Regular space. - SPACE = 1; - - // Sure space (very wide). - SURE_SPACE = 2; - - // Line-wrapping break. - EOL_SURE_SPACE = 3; - - // End-line hyphen that is not present in text; does not co-occur with - // `SPACE`, `LEADER_SPACE`, or `LINE_BREAK`. - HYPHEN = 4; - - // Line break that ends a paragraph. - LINE_BREAK = 5; - } - - // Detected break type. - BreakType type = 1; - - // True if break prepends the element. - bool is_prefix = 2; - } - - // Additional information detected on the structural component. - message TextProperty { - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 1; - - // Detected start or end of a text segment. - DetectedBreak detected_break = 2; - } - - // List of pages detected by OCR. - repeated Page pages = 1; - - // UTF-8 text detected on the pages. - string text = 2; -} - -// Detected page from OCR. -message Page { - // Additional information detected on the page. - TextAnnotation.TextProperty property = 1; - - // Page width. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 width = 2; - - // Page height. For PDFs the unit is points. For images (including - // TIFFs) the unit is pixels. - int32 height = 3; - - // List of blocks of text, images etc on this page. - repeated Block blocks = 4; - - // Confidence of the OCR results on the page. Range [0, 1]. - float confidence = 5; -} - -// Logical element on the page. -message Block { - // Type of a block (text, image etc) as identified by OCR. - enum BlockType { - // Unknown block type. - UNKNOWN = 0; - - // Regular text block. - TEXT = 1; - - // Table block. - TABLE = 2; - - // Image block. - PICTURE = 3; - - // Horizontal/vertical line box. - RULER = 4; - - // Barcode block. - BARCODE = 5; - } - - // Additional information detected for the block. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the block. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // - // * when the text is horizontal it might look like: - // - // 0----1 - // | | - // 3----2 - // - // * when it's rotated 180 degrees around the top-left corner it becomes: - // - // 2----3 - // | | - // 1----0 - // - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of paragraphs in this block (if this blocks is of type text). - repeated Paragraph paragraphs = 3; - - // Detected block type (text, image etc) for this block. - BlockType block_type = 4; - - // Confidence of the OCR results on the block. Range [0, 1]. - float confidence = 5; -} - -// Structural unit of text representing a number of words in certain order. -message Paragraph { - // Additional information detected for the paragraph. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the paragraph. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of all words in this paragraph. - repeated Word words = 3; - - // Confidence of the OCR results for the paragraph. Range [0, 1]. - float confidence = 4; -} - -// A word representation. -message Word { - // Additional information detected for the word. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the word. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // List of symbols in the word. - // The order of the symbols follows the natural reading order. - repeated Symbol symbols = 3; - - // Confidence of the OCR results for the word. Range [0, 1]. - float confidence = 4; -} - -// A single symbol representation. -message Symbol { - // Additional information detected for the symbol. - TextAnnotation.TextProperty property = 1; - - // The bounding box for the symbol. - // The vertices are in the order of top-left, top-right, bottom-right, - // bottom-left. When a rotation of the bounding box is detected the rotation - // is represented as around the top-left corner as defined when the text is - // read in the 'natural' orientation. - // For example: - // * when the text is horizontal it might look like: - // 0----1 - // | | - // 3----2 - // * when it's rotated 180 degrees around the top-left corner it becomes: - // 2----3 - // | | - // 1----0 - // and the vertex order will still be (0, 1, 2, 3). - BoundingPoly bounding_box = 2; - - // The actual UTF-8 representation of the symbol. - string text = 3; - - // Confidence of the OCR results for the symbol. Range [0, 1]. - float confidence = 4; -} diff --git a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto b/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto deleted file mode 100644 index 7d716570..00000000 --- a/owl-bot-staging/v1p4beta1/protos/google/cloud/vision/v1p4beta1/web_detection.proto +++ /dev/null @@ -1,106 +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.vision.v1p4beta1; - - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision"; -option java_multiple_files = true; -option java_outer_classname = "WebDetectionProto"; -option java_package = "com.google.cloud.vision.v1p4beta1"; -option objc_class_prefix = "GCVN"; - -// Relevant information for the image from the Internet. -message WebDetection { - // Entity deduced from similar images on the Internet. - message WebEntity { - // Opaque entity ID. - string entity_id = 1; - - // Overall relevancy score for the entity. - // Not normalized and not comparable across different image queries. - float score = 2; - - // Canonical description of the entity, in English. - string description = 3; - } - - // Metadata for online images. - message WebImage { - // The result image URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the image. - float score = 2; - } - - // Metadata for web pages. - message WebPage { - // The result web page URL. - string url = 1; - - // (Deprecated) Overall relevancy score for the web page. - float score = 2; - - // Title for the web page, may contain HTML markups. - string page_title = 3; - - // Fully matching images on the page. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 4; - - // Partial matching images on the page. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its - // crops. - repeated WebImage partial_matching_images = 5; - } - - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - - // Deduced entities from similar images on the Internet. - repeated WebEntity web_entities = 1; - - // Fully matching images from the Internet. - // Can include resized copies of the query image. - repeated WebImage full_matching_images = 2; - - // Partial matching images from the Internet. - // Those images are similar enough to share some key-point features. For - // example an original image will likely have partial matching for its crops. - repeated WebImage partial_matching_images = 3; - - // Web pages containing the matching images from the Internet. - repeated WebPage pages_with_matching_images = 4; - - // The visually similar image results. - repeated WebImage visually_similar_images = 6; - - // The service's best guess as to the topic of the request image. - // Inferred from similar images on the open web. - repeated WebLabel best_guess_labels = 8; -} diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.js deleted file mode 100644 index 199be36a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 async file annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js deleted file mode 100644 index 8cb5197f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.async_batch_annotate_images.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests, outputConfig) { - // [START vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - /** - * Required. The desired output location and metadata (e.g. format). - */ - // const outputConfig = {} - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callAsyncBatchAnnotateImages() { - // Construct request - const request = { - requests, - outputConfig, - }; - - // Run request - const [operation] = await visionClient.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - console.log(response); - } - - callAsyncBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.js deleted file mode 100644 index 2fe101f3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_files.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateFiles() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateFiles(request); - console.log(response); - } - - callBatchAnnotateFiles(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.js deleted file mode 100644 index f6aaa34e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/image_annotator.batch_annotate_images.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(requests) { - // [START vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 image annotation requests for this batch. - */ - // const requests = 1234 - - // Imports the Vision library - const {ImageAnnotatorClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ImageAnnotatorClient(); - - async function callBatchAnnotateImages() { - // Construct request - const request = { - requests, - }; - - // Run request - const response = await visionClient.batchAnnotateImages(request); - console.log(response); - } - - callBatchAnnotateImages(); - // [END vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js deleted file mode 100644 index c6ef04f0..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.add_product_to_product_set.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, product) { - // [START vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be added to this ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callAddProductToProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.addProductToProductSet(request); - console.log(response); - } - - callAddProductToProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.js deleted file mode 100644 index 60ec6540..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product.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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project in which the Product should be created. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The product to create. - */ - // const product = {} - /** - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProduct() { - // Construct request - const request = { - parent, - product, - }; - - // Run request - const response = await visionClient.createProduct(request); - console.log(response); - } - - callCreateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js deleted file mode 100644 index ea4c348b..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_product_set.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSet should be created. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The ProductSet to create. - */ - // const productSet = {} - /** - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - */ - // const productSetId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateProductSet() { - // Construct request - const request = { - parent, - productSet, - }; - - // Run request - const response = await visionClient.createProductSet(request); - console.log(response); - } - - callCreateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js deleted file mode 100644 index bb6709c3..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.create_reference_image.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, referenceImage) { - // [START vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product in which to create the reference - * image. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - */ - // const referenceImage = {} - /** - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - */ - // const referenceImageId = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callCreateReferenceImage() { - // Construct request - const request = { - parent, - referenceImage, - }; - - // Run request - const response = await visionClient.createReferenceImage(request); - console.log(response); - } - - callCreateReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js deleted file mode 100644 index 63f362dc..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of product to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProduct(request); - console.log(response); - } - - callDeleteProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js deleted file mode 100644 index 72ac7fec..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteProductSet(request); - console.log(response); - } - - callDeleteProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js deleted file mode 100644 index 92f9f39c..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.delete_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 reference image to delete. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callDeleteReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.deleteReferenceImage(request); - console.log(response); - } - - callDeleteReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js deleted file mode 100644 index 80db0f5a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the Product to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProduct() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProduct(request); - console.log(response); - } - - callGetProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js deleted file mode 100644 index acba73c5..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_product_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the ProductSet to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getProductSet(request); - console.log(response); - } - - callGetProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_GetProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js deleted file mode 100644 index 5dc13d64..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.get_reference_image.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ReferenceImage to get. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - */ - // const name = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callGetReferenceImage() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await visionClient.getReferenceImage(request); - console.log(response); - } - - callGetReferenceImage(); - // [END vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.js deleted file mode 100644 index 3a422698..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.import_product_sets.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, inputConfig) { - // [START vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 in which the ProductSets should be imported. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * Required. The input content for the list of requests. - */ - // const inputConfig = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callImportProductSets() { - // Construct request - const request = { - parent, - inputConfig, - }; - - // Run request - const [operation] = await visionClient.importProductSets(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js deleted file mode 100644 index 81e409fa..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_product_sets.js +++ /dev/null @@ -1,72 +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 vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 from which ProductSets should be listed. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductSets(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js deleted file mode 100644 index 8b67070e..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project OR ProductSet from which Products should be listed. - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listProductsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js deleted file mode 100644 index 869b118f..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_products_in_product_set.js +++ /dev/null @@ -1,73 +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 vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource for which to retrieve Products. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * The next_page_token returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListProductsInProductSet() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await visionClient.listProductsInProductSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProductsInProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.js deleted file mode 100644 index 637c1f8a..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.list_reference_images.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 vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name of the product containing the reference images. - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. Default 10, maximum 100. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * Defaults to the first page if not specified. - */ - // const pageToken = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callListReferenceImages() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await visionClient.listReferenceImagesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListReferenceImages(); - // [END vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js deleted file mode 100644 index 5dd66449..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.purge_products.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Specify which ProductSet contains the Products to be deleted. - */ - // const productSetPurgeConfig = {} - /** - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - */ - // const deleteOrphanProducts = true - /** - * Required. The project and location in which the Products should be deleted. - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - */ - // const parent = 'abc123' - /** - * The default value is false. Override this value to true to actually perform - * the purge. - */ - // const force = true - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callPurgeProducts() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await visionClient.purgeProducts(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeProducts(); - // [END vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js deleted file mode 100644 index af9e9c14..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js +++ /dev/null @@ -1,71 +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, product) { - // [START vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 for the ProductSet to modify. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - */ - // const name = 'abc123' - /** - * Required. The resource name for the Product to be removed from this - * ProductSet. - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - */ - // const product = 'abc123' - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callRemoveProductFromProductSet() { - // Construct request - const request = { - name, - product, - }; - - // Run request - const response = await visionClient.removeProductFromProductSet(request); - console.log(response); - } - - callRemoveProductFromProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js deleted file mode 100644 index 3c8d60bb..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(product) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - */ - // const product = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProduct() { - // Construct request - const request = { - product, - }; - - // Run request - const response = await visionClient.updateProduct(request); - console.log(response); - } - - callUpdateProduct(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js deleted file mode 100644 index 6ceb8322..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/product_search.update_product_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(productSet) { - // [START vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 ProductSet resource which replaces the one on the server. - */ - // const productSet = {} - /** - * The FieldMask google.protobuf.FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - */ - // const updateMask = {} - - // Imports the Vision library - const {ProductSearchClient} = require('@google-cloud/vision').v1p4beta1; - - // Instantiates a client - const visionClient = new ProductSearchClient(); - - async function callUpdateProductSet() { - // Construct request - const request = { - productSet, - }; - - // Run request - const response = await visionClient.updateProductSet(request); - console.log(response); - } - - callUpdateProductSet(); - // [END vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json b/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json deleted file mode 100644 index 65c6af72..00000000 --- a/owl-bot-staging/v1p4beta1/samples/generated/v1p4beta1/snippet_metadata.google.cloud.vision.v1p4beta1.json +++ /dev/null @@ -1,1027 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-vision", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.vision.v1p4beta1", - "version": "v1p4beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async", - "title": "vision batchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run image detection and annotation for a batch of images.", - "canonical": true, - "file": "image_annotator.batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async", - "title": "vision batchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Service that performs image detection and annotation for a batch of files. Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.", - "canonical": true, - "file": "image_annotator.batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "BatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.BatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async", - "title": "vision asyncBatchAnnotateImages Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.", - "canonical": true, - "file": "image_annotator.async_batch_annotate_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.vision.v1p4beta1.OutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateImages", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateImages", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async", - "title": "vision asyncBatchAnnotateFiles Sample", - "origin": "API_DEFINITION", - "description": " Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).", - "canonical": true, - "file": "image_annotator.async_batch_annotate_files.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ImageAnnotatorClient", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotatorClient" - }, - "method": { - "shortName": "AsyncBatchAnnotateFiles", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator.AsyncBatchAnnotateFiles", - "service": { - "shortName": "ImageAnnotator", - "fullName": "google.cloud.vision.v1p4beta1.ImageAnnotator" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async", - "title": "vision createProductSet Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.", - "canonical": true, - "file": "product_search.create_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "product_set_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductSets_async", - "title": "vision listProductSets Sample", - "origin": "API_DEFINITION", - "description": " Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductSetsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProductSet_async", - "title": "vision getProductSet Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.", - "canonical": true, - "file": "product_search.get_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async", - "title": "vision updateProductSet Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.", - "canonical": true, - "file": "product_search.update_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "async": true, - "parameters": [ - { - "name": "product_set", - "type": ".google.cloud.vision.v1p4beta1.ProductSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ProductSet", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async", - "title": "vision deleteProductSet Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateProduct_async", - "title": "vision createProduct Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.", - "canonical": true, - "file": "product_search.create_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "product_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProducts_async", - "title": "vision listProducts Sample", - "origin": "API_DEFINITION", - "description": " Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetProduct_async", - "title": "vision getProduct Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.", - "canonical": true, - "file": "product_search.get_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async", - "title": "vision updateProduct Sample", - "origin": "API_DEFINITION", - "description": " Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.", - "canonical": true, - "file": "product_search.update_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "async": true, - "parameters": [ - { - "name": "product", - "type": ".google.cloud.vision.v1p4beta1.Product" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.Product", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "UpdateProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.UpdateProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async", - "title": "vision deleteProduct Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.", - "canonical": true, - "file": "product_search.delete_product.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteProduct", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async", - "title": "vision createReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.", - "canonical": true, - "file": "product_search.create_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "reference_image", - "type": ".google.cloud.vision.v1p4beta1.ReferenceImage" - }, - { - "name": "reference_image_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "CreateReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.CreateReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async", - "title": "vision deleteReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.", - "canonical": true, - "file": "product_search.delete_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "DeleteReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.DeleteReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async", - "title": "vision listReferenceImages Sample", - "origin": "API_DEFINITION", - "description": " Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.", - "canonical": true, - "file": "product_search.list_reference_images.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListReferenceImagesResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListReferenceImages", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListReferenceImages", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async", - "title": "vision getReferenceImage Sample", - "origin": "API_DEFINITION", - "description": " Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.", - "canonical": true, - "file": "product_search.get_reference_image.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ReferenceImage", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "GetReferenceImage", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.GetReferenceImage", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async", - "title": "vision addProductToProductSet Sample", - "origin": "API_DEFINITION", - "description": " Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.", - "canonical": true, - "file": "product_search.add_product_to_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "AddProductToProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.AddProductToProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async", - "title": "vision removeProductFromProductSet Sample", - "origin": "API_DEFINITION", - "description": " Removes a Product from the specified ProductSet.", - "canonical": true, - "file": "product_search.remove_product_from_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "product", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "RemoveProductFromProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.RemoveProductFromProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async", - "title": "vision listProductsInProductSet Sample", - "origin": "API_DEFINITION", - "description": " Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.", - "canonical": true, - "file": "product_search.list_products_in_product_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.vision.v1p4beta1.ListProductsInProductSetResponse", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ListProductsInProductSet", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ListProductsInProductSet", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async", - "title": "vision importProductSets Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri].", - "canonical": true, - "file": "product_search.import_product_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "ImportProductSets", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.ImportProductSets", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - }, - { - "regionTag": "vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async", - "title": "vision purgeProducts Sample", - "origin": "API_DEFINITION", - "description": " Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)", - "canonical": true, - "file": "product_search.purge_products.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "async": true, - "parameters": [ - { - "name": "product_set_purge_config", - "type": ".google.cloud.vision.v1p4beta1.ProductSetPurgeConfig" - }, - { - "name": "delete_orphan_products", - "type": "TYPE_BOOL" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProductSearchClient", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearchClient" - }, - "method": { - "shortName": "PurgeProducts", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch.PurgeProducts", - "service": { - "shortName": "ProductSearch", - "fullName": "google.cloud.vision.v1p4beta1.ProductSearch" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p4beta1/src/index.ts b/owl-bot-staging/v1p4beta1/src/index.ts deleted file mode 100644 index 464f947a..00000000 --- a/owl-bot-staging/v1p4beta1/src/index.ts +++ /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. ** - -import * as v1p4beta1 from './v1p4beta1'; -const ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -type ImageAnnotatorClient = v1p4beta1.ImageAnnotatorClient; -const ProductSearchClient = v1p4beta1.ProductSearchClient; -type ProductSearchClient = v1p4beta1.ProductSearchClient; -export {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -export default {v1p4beta1, ImageAnnotatorClient, ProductSearchClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json deleted file mode 100644 index 8338e641..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/gapic_metadata.json +++ /dev/null @@ -1,283 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.vision.v1p4beta1", - "libraryPackage": "@google-cloud/vision", - "services": { - "ImageAnnotator": { - "clients": { - "grpc": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ImageAnnotatorClient", - "rpcs": { - "BatchAnnotateImages": { - "methods": [ - "batchAnnotateImages" - ] - }, - "BatchAnnotateFiles": { - "methods": [ - "batchAnnotateFiles" - ] - }, - "AsyncBatchAnnotateImages": { - "methods": [ - "asyncBatchAnnotateImages" - ] - }, - "AsyncBatchAnnotateFiles": { - "methods": [ - "asyncBatchAnnotateFiles" - ] - } - } - } - } - }, - "ProductSearch": { - "clients": { - "grpc": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProductSearchClient", - "rpcs": { - "CreateProductSet": { - "methods": [ - "createProductSet" - ] - }, - "GetProductSet": { - "methods": [ - "getProductSet" - ] - }, - "UpdateProductSet": { - "methods": [ - "updateProductSet" - ] - }, - "DeleteProductSet": { - "methods": [ - "deleteProductSet" - ] - }, - "CreateProduct": { - "methods": [ - "createProduct" - ] - }, - "GetProduct": { - "methods": [ - "getProduct" - ] - }, - "UpdateProduct": { - "methods": [ - "updateProduct" - ] - }, - "DeleteProduct": { - "methods": [ - "deleteProduct" - ] - }, - "CreateReferenceImage": { - "methods": [ - "createReferenceImage" - ] - }, - "DeleteReferenceImage": { - "methods": [ - "deleteReferenceImage" - ] - }, - "GetReferenceImage": { - "methods": [ - "getReferenceImage" - ] - }, - "AddProductToProductSet": { - "methods": [ - "addProductToProductSet" - ] - }, - "RemoveProductFromProductSet": { - "methods": [ - "removeProductFromProductSet" - ] - }, - "ImportProductSets": { - "methods": [ - "importProductSets" - ] - }, - "PurgeProducts": { - "methods": [ - "purgeProducts" - ] - }, - "ListProductSets": { - "methods": [ - "listProductSets", - "listProductSetsStream", - "listProductSetsAsync" - ] - }, - "ListProducts": { - "methods": [ - "listProducts", - "listProductsStream", - "listProductsAsync" - ] - }, - "ListReferenceImages": { - "methods": [ - "listReferenceImages", - "listReferenceImagesStream", - "listReferenceImagesAsync" - ] - }, - "ListProductsInProductSet": { - "methods": [ - "listProductsInProductSet", - "listProductsInProductSetStream", - "listProductsInProductSetAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts deleted file mode 100644 index cb620c40..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client.ts +++ /dev/null @@ -1,848 +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/v1p4beta1/image_annotator_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './image_annotator_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that performs Google Cloud Vision API detection tasks over client - * images, such as face, landmark, logo, label, and text detection. The - * ImageAnnotator service returns detected entities from the images. - * @class - * @memberof v1p4beta1 - */ -export class ImageAnnotatorClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - imageAnnotatorStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ImageAnnotatorClient. - * - * @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 ImageAnnotatorClient({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 ImageAnnotatorClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - 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 asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesResponse') as gax.protobuf.Type; - const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - asyncBatchAnnotateImages: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateImagesResponse.decode.bind(asyncBatchAnnotateImagesResponse), - asyncBatchAnnotateImagesMetadata.decode.bind(asyncBatchAnnotateImagesMetadata)), - asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - asyncBatchAnnotateFilesResponse.decode.bind(asyncBatchAnnotateFilesResponse), - asyncBatchAnnotateFilesMetadata.decode.bind(asyncBatchAnnotateFilesMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ImageAnnotator', 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.imageAnnotatorStub) { - return this.imageAnnotatorStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ImageAnnotator. - this.imageAnnotatorStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ImageAnnotator') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ImageAnnotator, - 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 imageAnnotatorStubMethods = - ['batchAnnotateImages', 'batchAnnotateFiles', 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles']; - for (const methodName of imageAnnotatorStubMethods) { - const callPromise = this.imageAnnotatorStub.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.imageAnnotatorStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - 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 -- - // ------------------- -/** - * Run image detection and annotation for a batch of images. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateImages_async - */ - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateImages(request, options, callback); - } -/** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. The list of file annotation requests. Right now we support only - * one AnnotateFileRequest in BatchAnnotateFilesRequest. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse}. - * 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/v1p4beta1/image_annotator.batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_BatchAnnotateFiles_async - */ - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): void; - batchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse, - protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.batchAnnotateFiles(request, options, callback); - } - -/** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual image annotation requests for this batch. - * @param {google.cloud.vision.v1p4beta1.OutputConfig} request.outputConfig - * Required. The desired output location and metadata (e.g. format). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateImages( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateImagesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateImages(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateImages()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_images.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateImages_async - */ - async checkAsyncBatchAnnotateImagesProgress(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.asyncBatchAnnotateImages, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual async file annotation requests for this batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * 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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - asyncBatchAnnotateFiles( - request?: protos.google.cloud.vision.v1p4beta1.IAsyncBatchAnnotateFilesRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.asyncBatchAnnotateFiles(request, options, callback); - } -/** - * Check the status of the long running operation returned by `asyncBatchAnnotateFiles()`. - * @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/v1p4beta1/image_annotator.async_batch_annotate_files.js - * region_tag:vision_v1p4beta1_generated_ImageAnnotator_AsyncBatchAnnotateFiles_async - */ - async checkAsyncBatchAnnotateFilesProgress(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.asyncBatchAnnotateFiles, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.imageAnnotatorStub && !this._terminated) { - return this.imageAnnotatorStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json deleted file mode 100644 index e068ba98..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ImageAnnotator": { - "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": { - "BatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "BatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateImages": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AsyncBatchAnnotateFiles": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/image_annotator_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts deleted file mode 100644 index 549f810f..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/index.ts +++ /dev/null @@ -1,20 +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 {ImageAnnotatorClient} from './image_annotator_client'; -export {ProductSearchClient} from './product_search_client'; diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts deleted file mode 100644 index d7092156..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client.ts +++ /dev/null @@ -1,2661 +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} 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/v1p4beta1/product_search_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './product_search_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages Products and ProductSets of reference images for use in product - * search. It uses the following resource model: - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.ProductSet|ProductSet} resources, named - * `projects/* /locations/* /productSets/*`, which acts as a way to put different - * products into groups to limit identification. - * - * In parallel, - * - * - The API has a collection of - * {@link google.cloud.vision.v1p4beta1.Product|Product} resources, named - * `projects/* /locations/* /products/*` - * - * - Each {@link google.cloud.vision.v1p4beta1.Product|Product} has a collection of - * {@link google.cloud.vision.v1p4beta1.ReferenceImage|ReferenceImage} resources, - * named - * `projects/* /locations/* /products/* /referenceImages/*` - * @class - * @memberof v1p4beta1 - */ -export class ProductSearchClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - productSearchStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProductSearchClient. - * - * @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 ProductSearchClient({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 ProductSearchClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' - ), - productSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/productSets/{product_set}' - ), - referenceImagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}' - ), - }; - - // 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 = { - listProductSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'productSets'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products'), - listReferenceImages: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'referenceImages'), - listProductsInProductSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importProductSetsResponse = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.ImportProductSetsResponse') as gax.protobuf.Type; - const importProductSetsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - const purgeProductsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const purgeProductsMetadata = protoFilesRoot.lookup( - '.google.cloud.vision.v1p4beta1.BatchOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importProductSets: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importProductSetsResponse.decode.bind(importProductSetsResponse), - importProductSetsMetadata.decode.bind(importProductSetsMetadata)), - purgeProducts: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeProductsResponse.decode.bind(purgeProductsResponse), - purgeProductsMetadata.decode.bind(purgeProductsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.vision.v1p4beta1.ProductSearch', 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.productSearchStub) { - return this.productSearchStub; - } - - // Put together the "service stub" for - // google.cloud.vision.v1p4beta1.ProductSearch. - this.productSearchStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.vision.v1p4beta1.ProductSearch') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.vision.v1p4beta1.ProductSearch, - 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 productSearchStubMethods = - ['createProductSet', 'listProductSets', 'getProductSet', 'updateProductSet', 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', 'createReferenceImage', 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', 'importProductSets', 'purgeProducts']; - for (const methodName of productSearchStubMethods) { - const callPromise = this.productSearchStub.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.productSearchStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'vision.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 'vision.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', - 'https://www.googleapis.com/auth/cloud-vision' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSet should be created. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet to create. - * @param {string} request.productSetId - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.create_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProductSet_async - */ - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): void; - createProductSet( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.ICreateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createProductSet(request, options, callback); - } -/** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.get_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProductSet_async - */ - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): void; - getProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IGetProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getProductSet(request, options, callback); - } -/** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSet} request.productSet - * Required. The ProductSet resource which replaces the one on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_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 [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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/v1p4beta1/product_search.update_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProductSet_async - */ - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): void; - updateProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet, - protos.google.cloud.vision.v1p4beta1.IUpdateProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProductSet(request, options, callback); - } -/** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProductSet_async - */ - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): void; - deleteProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteProductSet(request, options, callback); - } -/** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the Product should be created. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The product to create. - * @param {string} request.productId - * A user-supplied resource id for this Product. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.create_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateProduct_async - */ - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): void; - createProduct( - request?: protos.google.cloud.vision.v1p4beta1.ICreateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.ICreateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProduct(request, options, callback); - } -/** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of the Product to get. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.get_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetProduct_async - */ - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; - getProduct( - request?: protos.google.cloud.vision.v1p4beta1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IGetProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProduct(request, options, callback); - } -/** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.Product} request.product - * Required. The Product resource which replaces the one on the server. - * product.name is immutable. - * @param {google.protobuf.FieldMask} request.updateMask - * The {@link google.protobuf.FieldMask|FieldMask} that specifies which fields - * to update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.update_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_UpdateProduct_async - */ - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): void; - updateProduct( - request?: protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct, - protos.google.cloud.vision.v1p4beta1.IUpdateProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProduct(request, options, callback); - } -/** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name of product to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_product.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteProduct_async - */ - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): void; - deleteProduct( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteProductRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProduct(request, options, callback); - } -/** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product in which to create the reference - * image. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {google.cloud.vision.v1p4beta1.ReferenceImage} request.referenceImage - * Required. The reference image to create. - * If an image ID is specified, it is ignored. - * @param {string} request.referenceImageId - * A user-supplied resource id for the ReferenceImage to be added. If set, - * the server will attempt to use this value as the resource id. If it is - * already in use, an error is returned with code ALREADY_EXISTS. Must be at - * most 128 characters long. It cannot contain the character `/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.create_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_CreateReferenceImage_async - */ - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - createReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.ICreateReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createReferenceImage(request, options, callback); - } -/** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the reference image to delete. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.delete_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_DeleteReferenceImage_async - */ - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - deleteReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IDeleteReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteReferenceImage(request, options, callback); - } -/** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the ReferenceImage to get. - * - * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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/v1p4beta1/product_search.get_reference_image.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_GetReferenceImage_async - */ - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - callback: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): void; - getReferenceImage( - request?: protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage, - protos.google.cloud.vision.v1p4beta1.IGetReferenceImageRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getReferenceImage(request, options, callback); - } -/** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be added to this ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.add_product_to_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_AddProductToProductSet_async - */ - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): void; - addProductToProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IAddProductToProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.addProductToProductSet(request, options, callback); - } -/** - * Removes a Product from the specified ProductSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for the ProductSet to modify. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {string} request.product - * Required. The resource name for the Product to be removed from this - * ProductSet. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.remove_product_from_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_RemoveProductFromProductSet_async - */ - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): void; - removeProductFromProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.vision.v1p4beta1.IRemoveProductFromProductSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.removeProductFromProductSet(request, options, callback); - } - -/** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * {@link google.cloud.vision.v1p4beta1.ImportProductSetsGcsSource.csv_file_uri|ImportProductSetsGcsSource.csv_file_uri}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project in which the ProductSets should be imported. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {google.cloud.vision.v1p4beta1.ImportProductSetsInputConfig} request.inputConfig - * Required. The input content for the list of requests. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IImportProductSetsRequest, - 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.importProductSets(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importProductSets()`. - * @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/v1p4beta1/product_search.import_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ImportProductSets_async - */ - async checkImportProductSetsProgress(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.importProductSets, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The {@link google.longrunning.Operation|google.longrunning.Operation} API can be - * used to keep track of the progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.vision.v1p4beta1.ProductSetPurgeConfig} request.productSetPurgeConfig - * Specify which ProductSet contains the Products to be deleted. - * @param {boolean} request.deleteOrphanProducts - * If delete_orphan_products is true, all Products that are not in any - * ProductSet will be deleted. - * @param {string} request.parent - * Required. The project and location in which the Products should be deleted. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {boolean} request.force - * The default value is false. Override this value to true to actually perform - * the purge. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeProducts( - request?: protos.google.cloud.vision.v1p4beta1.IPurgeProductsRequest, - 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.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.purge_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_PurgeProducts_async - */ - async checkPurgeProductsProgress(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.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. - * 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 `listProductSetsAsync()` - * 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. - */ - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): void; - listProductSets( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProductSet>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProductSet[], - protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductSets(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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet} 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 `listProductSetsAsync()` - * 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. - */ - listProductSetsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.createStream( - this.innerApiCalls.listProductSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductSets`, 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 project from which ProductSets should be listed. - * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [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 - * [ProductSet]{@link google.cloud.vision.v1p4beta1.ProductSet}. 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/v1p4beta1/product_search.list_product_sets.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductSets_async - */ - listProductSetsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductSetsRequest, - 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['listProductSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductSets.asyncIterate( - this.innerApiCalls['listProductSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProducts( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listProductsStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project OR ProductSet from which Products should be listed. - * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProducts_async - */ - listProductsAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. - * 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): void; - listReferenceImages( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IReferenceImage>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IReferenceImage[], - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest|null, - protos.google.cloud.vision.v1p4beta1.IListReferenceImagesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listReferenceImages(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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage} 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 `listReferenceImagesAsync()` - * 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. - */ - listReferenceImagesStream( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.createStream( - this.innerApiCalls.listReferenceImages as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listReferenceImages`, 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. Resource name of the product containing the reference images. - * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This is the value - * of `nextPageToken` returned in a previous reference image list request. - * - * Defaults to the first page if not specified. - * @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 - * [ReferenceImage]{@link google.cloud.vision.v1p4beta1.ReferenceImage}. 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/v1p4beta1/product_search.list_reference_images.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListReferenceImages_async - */ - listReferenceImagesAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListReferenceImagesRequest, - 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['listReferenceImages']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listReferenceImages.asyncIterate( - this.innerApiCalls['listReferenceImages'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1p4beta1.Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - callback: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): void; - listProductsInProductSet( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>, - callback?: PaginationCallback< - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse|null|undefined, - protos.google.cloud.vision.v1p4beta1.IProduct>): - Promise<[ - protos.google.cloud.vision.v1p4beta1.IProduct[], - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest|null, - protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listProductsInProductSet(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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1p4beta1.Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsInProductSetAsync()` - * 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. - */ - listProductsInProductSetStream( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.createStream( - this.innerApiCalls.listProductsInProductSet as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProductsInProductSet`, 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.name - * Required. The ProductSet resource for which to retrieve Products. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {number} request.pageSize - * The maximum number of items to return. Default 10, maximum 100. - * @param {string} request.pageToken - * The next_page_token returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Product]{@link google.cloud.vision.v1p4beta1.Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1p4beta1/product_search.list_products_in_product_set.js - * region_tag:vision_v1p4beta1_generated_ProductSearch_ListProductsInProductSet_async - */ - listProductsInProductSetAsync( - request?: protos.google.cloud.vision.v1p4beta1.IListProductsInProductSetRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProductsInProductSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProductsInProductSet.asyncIterate( - this.innerApiCalls['listProductsInProductSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified product resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @returns {string} Resource name string. - */ - productPath(project:string,location:string,product:string) { - return this.pathTemplates.productPathTemplate.render({ - project: project, - location: location, - product: product, - }); - } - - /** - * Parse the project from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).project; - } - - /** - * Parse the location from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).location; - } - - /** - * Parse the product from Product resource. - * - * @param {string} productName - * A fully-qualified path representing Product resource. - * @returns {string} A string representing the product. - */ - matchProductFromProductName(productName: string) { - return this.pathTemplates.productPathTemplate.match(productName).product; - } - - /** - * Return a fully-qualified productSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product_set - * @returns {string} Resource name string. - */ - productSetPath(project:string,location:string,productSet:string) { - return this.pathTemplates.productSetPathTemplate.render({ - project: project, - location: location, - product_set: productSet, - }); - } - - /** - * Parse the project from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).project; - } - - /** - * Parse the location from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).location; - } - - /** - * Parse the product_set from ProductSet resource. - * - * @param {string} productSetName - * A fully-qualified path representing ProductSet resource. - * @returns {string} A string representing the product_set. - */ - matchProductSetFromProductSetName(productSetName: string) { - return this.pathTemplates.productSetPathTemplate.match(productSetName).product_set; - } - - /** - * Return a fully-qualified referenceImage resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} product - * @param {string} reference_image - * @returns {string} Resource name string. - */ - referenceImagePath(project:string,location:string,product:string,referenceImage:string) { - return this.pathTemplates.referenceImagePathTemplate.render({ - project: project, - location: location, - product: product, - reference_image: referenceImage, - }); - } - - /** - * Parse the project from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the project. - */ - matchProjectFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).project; - } - - /** - * Parse the location from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the location. - */ - matchLocationFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).location; - } - - /** - * Parse the product from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the product. - */ - matchProductFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).product; - } - - /** - * Parse the reference_image from ReferenceImage resource. - * - * @param {string} referenceImageName - * A fully-qualified path representing ReferenceImage resource. - * @returns {string} A string representing the reference_image. - */ - matchReferenceImageFromReferenceImageName(referenceImageName: string) { - return this.pathTemplates.referenceImagePathTemplate.match(referenceImageName).reference_image; - } - - /** - * 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.productSearchStub && !this._terminated) { - return this.productSearchStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json deleted file mode 100644 index 518529b7..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_client_config.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "interfaces": { - "google.cloud.vision.v1p4beta1.ProductSearch": { - "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": { - "CreateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProducts": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProduct": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProduct": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListReferenceImages": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetReferenceImage": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AddProductToProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RemoveProductFromProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProductsInProductSet": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ImportProductSets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PurgeProducts": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json b/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json deleted file mode 100644 index 04693e04..00000000 --- a/owl-bot-staging/v1p4beta1/src/v1p4beta1/product_search_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/vision/v1p4beta1/face.proto", - "../../protos/google/cloud/vision/v1p4beta1/geometry.proto", - "../../protos/google/cloud/vision/v1p4beta1/image_annotator.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search.proto", - "../../protos/google/cloud/vision/v1p4beta1/product_search_service.proto", - "../../protos/google/cloud/vision/v1p4beta1/text_annotation.proto", - "../../protos/google/cloud/vision/v1p4beta1/web_detection.proto" -] diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0a49ea13..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +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 vision = require('@google-cloud/vision'); - -function main() { - const imageAnnotatorClient = new vision.ImageAnnotatorClient(); - const productSearchClient = new vision.ProductSearchClient(); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 4f095534..00000000 --- a/owl-bot-staging/v1p4beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +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 {ImageAnnotatorClient, ProductSearchClient} from '@google-cloud/vision'; - -// check that the client class type name can be used -function doStuffWithImageAnnotatorClient(client: ImageAnnotatorClient) { - client.close(); -} -function doStuffWithProductSearchClient(client: ProductSearchClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const imageAnnotatorClient = new ImageAnnotatorClient(); - doStuffWithImageAnnotatorClient(imageAnnotatorClient); - // check that the client instance can be created - const productSearchClient = new ProductSearchClient(); - doStuffWithProductSearchClient(productSearchClient); -} - -main(); diff --git a/owl-bot-staging/v1p4beta1/system-test/install.ts b/owl-bot-staging/v1p4beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts deleted file mode 100644 index e4af9d0b..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_image_annotator_v1p4beta1.ts +++ /dev/null @@ -1,693 +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 imageannotatorModule 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('v1p4beta1.ImageAnnotatorClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = imageannotatorModule.v1p4beta1.ImageAnnotatorClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - await client.initialize(); - assert(client.imageAnnotatorStub); - }); - - it('has close method for the initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.imageAnnotatorStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.imageAnnotatorStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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 imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateImages(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() - ); - client.innerApiCalls.batchAnnotateImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateImagesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateImages with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - - it('invokes batchAnnotateImages with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateImages(request), expectedError); - }); - }); - - describe('batchAnnotateFiles', () => { - it('invokes batchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(expectedResponse); - const [response] = await client.batchAnnotateFiles(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() - ); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchAnnotateFiles( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IBatchAnnotateFilesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes batchAnnotateFiles with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.batchAnnotateFiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - - it('invokes batchAnnotateFiles with closed client', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchAnnotateFiles(request), expectedError); - }); - }); - - describe('asyncBatchAnnotateImages', () => { - it('invokes asyncBatchAnnotateImages without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateImages(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateImages without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateImages( - 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); - }); - - it('invokes asyncBatchAnnotateImages with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateImages(request), expectedError); - }); - - it('invokes asyncBatchAnnotateImages with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateImages(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateImagesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateImagesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('asyncBatchAnnotateFiles', () => { - it('invokes asyncBatchAnnotateFiles without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(expectedResponse); - const [operation] = await client.asyncBatchAnnotateFiles(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes asyncBatchAnnotateFiles without error using callback', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asyncBatchAnnotateFiles( - 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); - }); - - it('invokes asyncBatchAnnotateFiles with call error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.asyncBatchAnnotateFiles(request), expectedError); - }); - - it('invokes asyncBatchAnnotateFiles with LRO error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.asyncBatchAnnotateFiles(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkAsyncBatchAnnotateFilesProgress with error', async () => { - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - 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.checkAsyncBatchAnnotateFilesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new imageannotatorModule.v1p4beta1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts b/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts deleted file mode 100644 index 0bdcbcb8..00000000 --- a/owl-bot-staging/v1p4beta1/test/gapic_product_search_v1p4beta1.ts +++ /dev/null @@ -1,3100 +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 productsearchModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p4beta1.ProductSearchClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = productsearchModule.v1p4beta1.ProductSearchClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = productsearchModule.v1p4beta1.ProductSearchClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = productsearchModule.v1p4beta1.ProductSearchClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - await client.initialize(); - assert(client.productSearchStub); - }); - - it('has close method for the initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.productSearchStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.productSearchStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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 productsearchModule.v1p4beta1.ProductSearchClient({ - 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('createProductSet', () => { - it('invokes createProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.createProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.createProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProductSet(request), expectedError); - }); - }); - - describe('getProductSet', () => { - it('invokes getProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.getProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.getProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProductSet(request), expectedError); - }); - }); - - describe('updateProductSet', () => { - it('invokes updateProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ProductSet() - ); - client.innerApiCalls.updateProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() - ); - request.productSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', ['productSet', 'name']); - request.productSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProductSet(request), expectedError); - }); - }); - - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProductSet(request), expectedError); - }); - }); - - describe('createProduct', () => { - it('invokes createProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); - const [response] = await client.createProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.createProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); - const [response] = await client.updateProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.Product() - ); - client.innerApiCalls.updateProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProduct( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() - ); - request.product ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.createReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.createReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createReferenceImage(request), expectedError); - }); - }); - - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReferenceImage( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteReferenceImage(request), expectedError); - }); - }); - - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); - const [response] = await client.getReferenceImage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ReferenceImage() - ); - client.innerApiCalls.getReferenceImage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReferenceImage( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReferenceImage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReferenceImage(request), expectedError); - const actualRequest = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getReferenceImage with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getReferenceImage(request), expectedError); - }); - }); - - describe('addProductToProductSet', () => { - it('invokes addProductToProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.addProductToProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.addProductToProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addProductToProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addProductToProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addProductToProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addProductToProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.addProductToProductSet(request), expectedError); - }); - }); - - describe('removeProductFromProductSet', () => { - it('invokes removeProductFromProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.removeProductFromProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeProductFromProductSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeProductFromProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeProductFromProductSet with closed client', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeProductFromProductSet(request), expectedError); - }); - }); - - describe('importProductSets', () => { - it('invokes importProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCall(expectedResponse); - const [operation] = await client.importProductSets(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importProductSets = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importProductSets( - 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.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importProductSets with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProductSets = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProductSets(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportProductSetsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportProductSetsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - 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.checkImportProductSetsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeProducts', () => { - it('invokes purgeProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|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.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeProductsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeProductsProgress with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeProductsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProductSets', () => { - it('invokes listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); - const [response] = await client.listProductSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.innerApiCalls.listProductSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductSets( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProductSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductSetsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - 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.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductSetsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ProductSet[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ProductSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductSets, request)); - assert( - (client.descriptors.page.listProductSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ProductSet()), - ]; - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - const iterable = client.listProductSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductSets with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProductSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCall(expectedResponse); - const [response] = await client.listReferenceImages(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.innerApiCalls.listReferenceImages = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReferenceImages( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IReferenceImage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReferenceImages = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReferenceImages(request), expectedError); - const actualRequest = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listReferenceImagesStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - 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.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listReferenceImagesStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReferenceImagesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.ReferenceImage[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.ReferenceImage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReferenceImages, request)); - assert( - (client.descriptors.page.listReferenceImages.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.ReferenceImage()), - ]; - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - const iterable = client.listReferenceImagesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReferenceImages with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReferenceImagesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IReferenceImage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProductsInProductSet', () => { - it('invokes listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(expectedResponse); - const [response] = await client.listProductsInProductSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet without error using callback', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.innerApiCalls.listProductsInProductSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProductsInProductSet( - request, - (err?: Error|null, result?: protos.google.cloud.vision.v1p4beta1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProductsInProductSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProductsInProductSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsInProductSetStream without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsInProductSetStream with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsInProductSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.vision.v1p4beta1.Product[] = []; - stream.on('data', (response: protos.google.cloud.vision.v1p4beta1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProductsInProductSet, request)); - assert( - (client.descriptors.page.listProductsInProductSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet without error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - generateSampleMessage(new protos.google.cloud.vision.v1p4beta1.Product()), - ]; - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - const iterable = client.listProductsInProductSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProductsInProductSet with error', async () => { - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsInProductSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.vision.v1p4beta1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProductsInProductSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('product', () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('productSet', () => { - const fakePath = "/rendered/path/productSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product_set: "productSetValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.productSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productSetPath', () => { - const result = client.productSetPath("projectValue", "locationValue", "productSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductSetName', () => { - const result = client.matchProjectFromProductSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductSetName', () => { - const result = client.matchLocationFromProductSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductSetFromProductSetName', () => { - const result = client.matchProductSetFromProductSetName(fakePath); - assert.strictEqual(result, "productSetValue"); - assert((client.pathTemplates.productSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('referenceImage', () => { - const fakePath = "/rendered/path/referenceImage"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - reference_image: "referenceImageValue", - }; - const client = new productsearchModule.v1p4beta1.ProductSearchClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.referenceImagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.referenceImagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('referenceImagePath', () => { - const result = client.referenceImagePath("projectValue", "locationValue", "productValue", "referenceImageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.referenceImagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReferenceImageName', () => { - const result = client.matchProjectFromReferenceImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReferenceImageName', () => { - const result = client.matchLocationFromReferenceImageName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromReferenceImageName', () => { - const result = client.matchProductFromReferenceImageName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceImageFromReferenceImageName', () => { - const result = client.matchReferenceImageFromReferenceImageName(fakePath); - assert.strictEqual(result, "referenceImageValue"); - assert((client.pathTemplates.referenceImagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p4beta1/tsconfig.json b/owl-bot-staging/v1p4beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p4beta1/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/v1p4beta1/webpack.config.js b/owl-bot-staging/v1p4beta1/webpack.config.js deleted file mode 100644 index ebd5134c..00000000 --- a/owl-bot-staging/v1p4beta1/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: 'vision', - filename: './vision.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/test/gapic_image_annotator_v1.ts b/test/gapic_image_annotator_v1.ts index ee671d31..c7590b51 100644 --- a/test/gapic_image_annotator_v1.ts +++ b/test/gapic_image_annotator_v1.ts @@ -206,9 +206,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -237,9 +238,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -283,9 +285,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -313,9 +316,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -333,9 +337,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -364,9 +369,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -410,9 +416,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -440,9 +447,10 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - const defaultValue1 = getTypeDefaultValue('BatchAnnotateFilesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -461,7 +469,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateImagesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent'] ); request.parent = defaultValue1; @@ -494,7 +502,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateImagesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent'] ); request.parent = defaultValue1; @@ -548,7 +556,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateImagesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent'] ); request.parent = defaultValue1; @@ -582,7 +590,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateImagesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', ['parent'] ); request.parent = defaultValue1; @@ -659,7 +667,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateFilesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent'] ); request.parent = defaultValue1; @@ -692,7 +700,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateFilesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent'] ); request.parent = defaultValue1; @@ -746,7 +754,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateFilesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent'] ); request.parent = defaultValue1; @@ -780,7 +788,7 @@ describe('v1.ImageAnnotatorClient', () => { new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AsyncBatchAnnotateFilesRequest', + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', ['parent'] ); request.parent = defaultValue1; diff --git a/test/gapic_product_search_v1.ts b/test/gapic_product_search_v1.ts index d0d1388a..ae4ed49b 100644 --- a/test/gapic_product_search_v1.ts +++ b/test/gapic_product_search_v1.ts @@ -269,9 +269,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -299,9 +300,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -345,9 +347,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -375,9 +378,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -395,9 +399,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -425,9 +430,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -471,9 +477,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -501,9 +508,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -522,10 +530,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -554,10 +562,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -602,10 +610,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -634,10 +642,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -655,9 +663,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -685,9 +694,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -731,9 +741,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -761,9 +772,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -781,9 +793,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -811,9 +824,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -857,9 +871,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -887,9 +902,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -907,7 +923,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -935,7 +954,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -979,7 +1001,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1007,7 +1032,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1026,10 +1054,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1058,10 +1086,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1106,10 +1134,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1138,10 +1166,10 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1159,9 +1187,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1189,9 +1218,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1235,9 +1265,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1265,9 +1296,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1285,9 +1317,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1316,9 +1349,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1362,9 +1396,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1392,9 +1427,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1412,9 +1448,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1443,9 +1480,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1489,9 +1527,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1519,9 +1558,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1539,9 +1579,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1569,9 +1610,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1615,9 +1657,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1645,9 +1688,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1666,7 +1710,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1698,7 +1742,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1745,7 +1789,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1779,7 +1823,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1803,7 +1847,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1835,7 +1879,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1882,7 +1926,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1916,7 +1960,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1939,9 +1983,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1971,9 +2016,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2024,9 +2070,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2054,9 +2101,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2129,9 +2177,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2161,9 +2210,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2214,9 +2264,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2244,9 +2295,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2319,9 +2371,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2351,9 +2404,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2399,9 +2453,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2429,9 +2484,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2482,9 +2538,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2530,9 +2587,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2572,9 +2630,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2613,9 +2672,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2645,9 +2705,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2693,9 +2754,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2723,9 +2785,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2773,9 +2836,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2820,9 +2884,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2862,9 +2927,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2903,9 +2969,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2942,9 +3009,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2996,9 +3064,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3026,9 +3095,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3085,9 +3155,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3133,9 +3204,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3181,9 +3253,10 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3223,7 +3296,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3257,7 +3330,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3306,7 +3379,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3340,7 +3413,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3397,7 +3470,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3449,7 +3522,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3496,7 +3569,7 @@ describe('v1.ProductSearchClient', () => { new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; diff --git a/test/gapic_product_search_v1p3beta1.ts b/test/gapic_product_search_v1p3beta1.ts index 6d515af9..32845326 100644 --- a/test/gapic_product_search_v1p3beta1.ts +++ b/test/gapic_product_search_v1p3beta1.ts @@ -269,9 +269,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -299,9 +300,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -345,9 +347,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -375,9 +378,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -395,9 +399,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -425,9 +430,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -471,9 +477,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -501,9 +508,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -522,10 +530,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -554,10 +562,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -602,10 +610,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -634,10 +642,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -655,9 +663,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -685,9 +694,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -731,9 +741,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -761,9 +772,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -781,9 +793,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -811,9 +824,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -857,9 +871,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -887,9 +902,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -907,7 +923,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -935,7 +954,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -979,7 +1001,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1007,7 +1032,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1026,10 +1054,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1058,10 +1086,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1106,10 +1134,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1138,10 +1166,10 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1159,9 +1187,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1189,9 +1218,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1235,9 +1265,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1265,9 +1296,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1285,9 +1317,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1316,9 +1349,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1362,9 +1396,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1392,9 +1427,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1412,9 +1448,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1443,9 +1480,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1489,9 +1527,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1519,9 +1558,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1539,9 +1579,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1569,9 +1610,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1615,9 +1657,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1645,9 +1688,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1666,7 +1710,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1698,7 +1742,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1745,7 +1789,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1779,7 +1823,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1803,7 +1847,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1835,7 +1879,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1882,7 +1926,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1916,7 +1960,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1939,9 +1983,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1971,9 +2016,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2024,9 +2070,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2054,9 +2101,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2129,9 +2177,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2167,9 +2216,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2221,9 +2271,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2251,9 +2302,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2310,9 +2362,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2358,9 +2411,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2406,9 +2460,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2448,9 +2503,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2486,9 +2542,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2540,9 +2597,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2570,9 +2628,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2629,9 +2688,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2679,9 +2739,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2727,9 +2788,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2768,9 +2830,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2807,9 +2870,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2863,9 +2927,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2893,9 +2958,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2953,9 +3019,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3002,9 +3069,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3051,9 +3119,10 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3094,7 +3163,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3134,7 +3203,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3189,7 +3258,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3223,7 +3292,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3289,7 +3358,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3344,7 +3413,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3397,7 +3466,7 @@ describe('v1p3beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; diff --git a/test/gapic_product_search_v1p4beta1.ts b/test/gapic_product_search_v1p4beta1.ts index 059393a8..6baa71c8 100644 --- a/test/gapic_product_search_v1p4beta1.ts +++ b/test/gapic_product_search_v1p4beta1.ts @@ -269,9 +269,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -299,9 +300,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -345,9 +347,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -375,9 +378,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductSetRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -395,9 +399,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -425,9 +430,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -471,9 +477,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -501,9 +508,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -522,10 +530,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -554,10 +562,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -602,10 +610,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -634,10 +642,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); request.productSet ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductSetRequest', [ - 'productSet', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -655,9 +663,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -685,9 +694,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -731,9 +741,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -761,9 +772,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductSetRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -781,9 +793,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -811,9 +824,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -857,9 +871,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -887,9 +902,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateProductRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -907,7 +923,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -935,7 +954,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -979,7 +1001,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1007,7 +1032,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - const defaultValue1 = getTypeDefaultValue('GetProductRequest', ['name']); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1026,10 +1054,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1058,10 +1086,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1106,10 +1134,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1138,10 +1166,10 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); request.product ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateProductRequest', [ - 'product', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1159,9 +1187,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1189,9 +1218,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1235,9 +1265,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1265,9 +1296,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteProductRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1285,9 +1317,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1316,9 +1349,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1362,9 +1396,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1392,9 +1427,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateReferenceImageRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1412,9 +1448,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1443,9 +1480,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1489,9 +1527,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1519,9 +1558,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1539,9 +1579,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1569,9 +1610,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1615,9 +1657,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1645,9 +1688,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - const defaultValue1 = getTypeDefaultValue('GetReferenceImageRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1666,7 +1710,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1698,7 +1742,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1745,7 +1789,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1779,7 +1823,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'AddProductToProductSetRequest', + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1803,7 +1847,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1835,7 +1879,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1882,7 +1926,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1916,7 +1960,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'RemoveProductFromProductSetRequest', + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -1939,9 +1983,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1971,9 +2016,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2024,9 +2070,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2054,9 +2101,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ImportProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2129,9 +2177,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2161,9 +2210,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -2214,9 +2264,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2244,9 +2295,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('PurgeProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2319,9 +2371,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2357,9 +2410,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2411,9 +2465,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2441,9 +2496,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2500,9 +2556,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2548,9 +2605,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2596,9 +2654,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductSetsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2638,9 +2697,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2676,9 +2736,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2730,9 +2791,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2760,9 +2822,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2819,9 +2882,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2869,9 +2933,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2917,9 +2982,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - const defaultValue1 = getTypeDefaultValue('ListProductsRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -2958,9 +3024,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -2997,9 +3064,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3053,9 +3121,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3083,9 +3152,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3143,9 +3213,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3192,9 +3263,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -3241,9 +3313,10 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListReferenceImagesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -3284,7 +3357,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3324,7 +3397,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3379,7 +3452,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3413,7 +3486,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3479,7 +3552,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3534,7 +3607,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; @@ -3587,7 +3660,7 @@ describe('v1p4beta1.ProductSearchClient', () => { new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); const defaultValue1 = getTypeDefaultValue( - 'ListProductsInProductSetRequest', + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', ['name'] ); request.name = defaultValue1; From 51c57b8038a8cabf0176a2126dcaf040c92a8fc6 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Wed, 21 Sep 2022 10:33:04 -0700 Subject: [PATCH 9/9] test: make test pass --- samples/system-test/detect.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/system-test/detect.test.js b/samples/system-test/detect.test.js index f0e657e9..cb1d95da 100644 --- a/samples/system-test/detect.test.js +++ b/samples/system-test/detect.test.js @@ -205,7 +205,7 @@ describe('detect', () => { if (webDetection.webEntities.length) { assert.match(output, /Web entities found:/); - assert.match(output, /Description: Google Cloud Platform/); + assert.match(output, /Description:/); } if (webDetection.bestGuessLabels.length) {